Click to See Complete Forum and Search --> : register_globals


gyoung
07-16-2003, 07:35 AM
$GLOBALS is supposedly "automatically global" - a "superglobal".

I took this to mean that the $GLOBALS array would be available with "register_globals = off" (php.ini file).

I have just upgraded to PHP 4.3.2 where "register_globals = off" is the default, but this does not seem to be the case:

echo $GLOBALS["SCRIPT_NAME"]; // no value

If I make "register_globals = on" it works as usual:

echo $GLOBALS["SCRIPT_NAME"]; // /myscript.php

(I have installed 4.3.2 on both Linux and Windows and the same thing happens on each platform.)

Can I access the $GLOBALS array without setting "register_globals = on"?

tsinka
07-17-2003, 08:05 AM
Hi,

try to use

$_SERVER["SCRIPT_NAME"]

if register_globals is set to off. The script name should be in $_SERVER in this case not in $GLOBALS.


Thomas

gyoung
07-17-2003, 12:55 PM
That works, thanks.

Still a bit confused by the documentation though...

skiing900
07-23-2003, 03:59 PM
I am using the function $GLOBALS["SCRIPT_NAME"]; to try to locate the current webpage (script) being used, but instead it just returns the value /php/php.exe, I want something that gives me the current script in use. okay, I found this $_SERVER['PHP_SELF'] and that works, except, I need just the name of the document in use instead of the path also. So my desired output would be currentdoc.php instead of currentdocspaths/currentdoc.php Any suggestions?

tsinka
07-24-2003, 03:47 AM
Hi,

you can use the basename function.

http://www.php.net/manual/en/function.basename.php