Help us understand the problem. What is going on with this article?

PHPで現在アクセスされているページのURLを取得する

More than 3 years have passed since last update.

PHPで現在アクセスされているページのURLを取得する

■about

PHPで現在アクセスされているページのURLを取得する

■code

現在のページ自体

php
echo $_SERVER["REQUEST_URI"];

ホスト名も取得する場合

php
echo $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];

プロトコルも取得する場合

php
echo (empty($_SERVER["HTTPS"]) ? "http://" : "https://") . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];

■reference

PHPで現在アクセスされているページのURLを取得する - hoge256ブログ
http://www.hoge256.net/2010/06/519.html

$SERVER変数|PHP情報|株式会社エン・PCサービス
http://www.en-pc.jp/php
server.php

$_SERVER
http://www.php.net//manual/ja/reserved.variables.server.php

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした