We can get the current file name or the file executing the code by using SCRIPT_NAME. This will give us the path from the server root so the name of the current directory will also be included. Here is the code.
Example:
If you want to get the last PHP script name from the following path
Path: /my_file/test.php
Then we can use the following code
Code.
$file = $_SERVER["SCRIPT_NAME"];
$break = Explode('/', $file);
$pfile = $break[count($break) - 1];
echo $pfile;
$break = Explode('/', $file);
$pfile = $break[count($break) - 1];
echo $pfile;
Output: test.php
0 comments:
Post a Comment
Thanks for your valuable Comment