Entry
Why is $PHP_SELF empty from a Netscape browser but not from IE?
Aug 12th, 2000 07:48
kwaH, Nathan Wallace, David Deutsch, Sascha Schumann
Using the line:
<A HREF="<? echo $PHP_SELF; ?>?var=something">Link Name</a>
you might get these links (as they appear in the View Source of the
browser):
URL in IE: http://myhost.com/phpfile.php3?var=something
URL in Netscape: http://myhost.com/?var=something
$PHP_SELF is probably empty in both cases. Netscape doesn't conform to
RFC 2068 which says in "3.2.1 General Syntax" that URIs of the form
?query
are valid. IE does handle these just fine and probably combines them to
a correct URI while Netscape doesn't.
You can echo $PHP_SELF somewhere in your document where it's not part of
a link to check.
In case you have created the hyperlink from within a function or class,
you might just have forgotten to import the variable $PHP_SELF from
the global variable space.
In that case a simple
global $PHP_SELF
should do the job.
A complete example might look like this:
function DoSomething() {
global $PHP_SELF;
printf ("<a href='%s?func=browse'>Browse</a>", $PHP_SELF);
return true;
}