Hi,
how do I get the name of the current script? For example the current script is test.php, is there a code or something to get the script name?
$GLOBALS['PHP_SELF'];
should work
Originally posted by dta $GLOBALS['PHP_SELF']; should work [/B]
Originally posted by dta
should work [/B]
or $_SERVER['PHP_SELF']
🙂
print_r ($_SERVER);
AND GO READ THE MANUAL!!! ( It's under Predefined Variables )
niether one of those will work, as they get the path as well. seems shelbytll just wants the script name
so use:
basename($_SERVER['SCRIPT_NAME']);
-- cheers
Originally posted by seby niether one of those will work, as they get the path as well. seems shelbytll just wants the script name so use: basename($_SERVER['SCRIPT_NAME']); -- cheers [/B]
Originally posted by seby niether one of those will work, as they get the path as well. seems shelbytll just wants the script name so use:
-- cheers [/B]
before you go saying everyone else is wrong... how about checking yourself? :rolleyes:
REQUEST_URI = /test/temp.php SCRIPT_NAME = /test/temp.php PHP_SELF = /test/temp.php
thanks to
<? foreach($_SERVER as $key => $val) { echo "$key = $val<br>"; } ?>
for the output.....
and to end this debate....
$script = end(explode('/', $_SERVER['PHP_SELF']));
that will return JUST the file.php
[edit -- just now saw basename() up there... that would work too, wonder why I always forget about that function --]
Nother way to skin the cat
$page = substr(strrchr($_SERVER['PHP_SELF'], "/"), 1);