I'm trying to fetch the filename of my php file. Out of curiosity i was wondering if there are any alternative way of doing this besides.
echo "<br/>".basename($_SERVER['PHP_SELF']);
I'm trying to fetch the filename of my php file. Out of curiosity i was wondering if there are any alternative way of doing this besides.
echo "<br/>".basename($_SERVER['PHP_SELF']);
Php has a magic constant that return the file path : __FILE__
if you only want the file name, use basename(__FILE__)
The advantage is that it will work even for a php script called via CLI and not executed by a web server / cgi.