JustinK101 Posted February 1, 2007 Share Posted February 1, 2007 How do I just get the filename of the current executing file? I have tried echo $_SERVER['REQUEST_URI']; but that is not what I want. That returns the folder you are in as well. I need only the filename. It must be universal though, for example if somebody is running index.php at the following: http://www.mydomain.com/myfolder/index.php I need only index.php to be returned. The same goes for: http://mysubdomain.mydomain.com/index.php and http://www.mydomain.com/index.php I need only index.php to be returned. Thanks. Link to comment https://forums.phpfreaks.com/topic/36705-how-to-get-the-filename-of-current-executing-script/ Share on other sites More sharing options...
janroald Posted February 1, 2007 Share Posted February 1, 2007 echo basename($_SERVER['REQUEST_URI']); Link to comment https://forums.phpfreaks.com/topic/36705-how-to-get-the-filename-of-current-executing-script/#findComment-175048 Share on other sites More sharing options...
Daniel0 Posted February 1, 2007 Share Posted February 1, 2007 You could use <?php echo basename(__FILE__); ?> as well, but this takes the filename of the script it is located in, so if it is inside functions.php it will echo functions.php. Link to comment https://forums.phpfreaks.com/topic/36705-how-to-get-the-filename-of-current-executing-script/#findComment-175050 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.