How to get the name of PHP script

To extract the name of the currently executed script from the URL, The PHP superglobal array $_SERVER can be used.The example below describes the procedure.

$currentscript = $_SERVER["PHP_SELF"];
echo $currentscript;

The PHP code above will show the name of only the PHP script currently executed.Sometimes it is necessary only to get the name of the PHP script instead of complete URL.



Post a Comment