note 40710 deleted from ref.url by nlopess
| From: | nlopess@php.net | Date: | Fri, 12 Mar 2004 14:39:01 +0000 |
| Subject: | note 40710 deleted from ref.url by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-66725@lists.php.net to get a copy of this message | ||
Note Submitter: Hans Luijten (www.weethet.nl)
----
I have been toying a bit with retrieving the (relative) path of the URL of the page you're
working on right now.
I experienced some nice problems with pre-defined variables, in combination with the different
settings of different servers.
My goal was to retrieve both "index.php" as a link, and
"index.php?var1=123&var2=456" ...
I found this to work pretty OK:
error_reporting(0); // No error reporting
// Try to retrieve the required values
$PageLink=$_SERVER['PHP_SELF'];
$PageParams=$_SERVER['QUERY_STRING'];
error_reporting(E_ALL); // Error reporting on
if ($PageParams)
{
echo $PageLink.'?'.$PageParams;
}
else
{
echo $PageLink;
}
Figured it might be useful for other users ...