today i wills how you how you can get the current working file name. sometimes, its good to know what is the name of the file the script is running on for your code. for example when you are running the fopen() functions and others like it. so today i will show you how you can get the current script file name in PHP with this simple step by step tutorial, so follow these steps.

lets say you have a file called webune.php, if you want to find out what the name of the file is you can use this code:

<?PHP
# SCRIPT PROVIDED BY WEBUNE.COM
function GetFileName($php_self){
$filename = explode("/", $php_self); // THIS WILL BREAK DOWN THE PATH INTO AN ARRAY
$filename = array_reverse($filename ); // THIS WILL MAKE THE LAST ELEMENT THE FIRST
return $filename[0];
}
echo 'The name of this file is: '.GetFileName($_SERVER['PHP_SELF']);
?>


so when you run this script the output will say:

The name of this file is: webune.php

hope this helps