|
Posted by Rik on 06/06/07 22:15
On Thu, 07 Jun 2007 00:03:09 +0200, zoilus <zolius@someplace.org> wrote:=
> I had been trying this one and a few others without success, until I =
> used this
>
> // $PHP_SELF=3D$_SERVER['PHP_SELF']; //r&d
> // print "$PHP_SELF"; //r&d
>
> The above worked while others just blanked my php output.
Some pointers:
- Never ever use the <?=3D$varname ?> syntax. (Which assumes both shortt=
ags =
and register_globals set to On, both of which are a Bad Idea)
- Do not expect any magic variable to exist except the ones listed on =
http://www.php.net/manual/en/language.variables.predefined.php (well, =
including $this in classes etc.)
Also, putting double quotes around a single variable to echo, print, or =
do =
anything else with it is just plain silly. All it does is it casts it to=
a =
string, which is already assumed by echo/print constructs. If you really=
=
need to cast it to a string, using strval() (only for scalars) or =
(string)$varname is preferred. See =
http://www.php.net/manual/en/language.types.type-juggling.php for more =
details on this.
Short answer:
<?php echo $_SERVER['PHP_SELF']; ?> works almost all the time, depending=
=
on what webserver you use (as it isn't provided by PHP itself, the serve=
r =
tells PHP what it should be).
-- =
Rik Wasmus
[Back to original message]
|