Click to See Complete Forum and Search --> : $SERVER_ADDR and $PHP_SELF, $REMOTE_ADDR
I can't echo the variables like $SERVER_ADDR and $PHP_SELF, $REMOTE_ADDR
It works on my liveserver but not on my localserver. so its no syntax error.
The function phpinfo() works and gives me these variables in its listtable.
I can also echo normal variables and strings.
I am using apache on win2000 with php4.1.1
I tried it with the php.exe and phpapachemodul.
sayoko
02-28-2002, 12:23 PM
ThereŽs been some changes in php 4.1.
Look into your php.ini if register globals is on. I think if its in off, those variables donŽt get registered.
As for variables in general, create a script with phpinfo() in it. YouŽll notice that a lot of variables changed, e.g. $SERVER_ADDR is now $_SERVER["SERVER_ADDR"]
Look into the changelog on php.net, its described there why this was changed.
vincente
03-01-2002, 12:12 PM
"YouŽll notice that a lot of variables changed, e.g. $SERVER_ADDR is now $_SERVER["SERVER_ADDR"]"
Not completely true.
$SERVER_ADDR is still $SERVER_ADDR.
But., all the server vars used to be available in $HTTP_SERVER_VARS. PHP have decided to rename that array to $_SERVER.
In 4.1.x, _all_ the old options are still available, but they will be dropped in future releases.
Accessing 'global' variables is never a good idea, always specify where you want to get the value from, because that will work on _any_ installation of PHP:
echo $HTTP_SERVER_VARS['SERVER_ADDR'];
or in 4.1.x:
echo $_SERVER['SERVER_ADDR'];
Hmm, doesnŽt that one vanish too like $PHP_SELF does when I turn globals off? Well, my mistake then :)
vincente
03-02-2002, 06:52 AM
Nope, register_globals just copies the vars from the $HTTP_*_VARS arrays to the global scope, but the original arrays are always available.
$GLOBALS['PHP_SELF'] etc. will work.
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.