How can I get the only name of the current executing file?
Answer Posted / nilsoft
There are too many solutions. But i am showing 4 among them
Method 1.
$file = trim($_SERVER["SCRIPT_NAME"],'/');
Method 2.
$file =
substr($_SERVER["SCRIPT_NAME"],1,strlen($_SERVER["SCRIPT_NAME"])-1);
Method 3.
$file = str_replace('/','',$_SERVER["SCRIPT_NAME"]);
Method 4.
$file = basename($_SERVER["SCRIPT_NAME"]);
and so on............
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
How to convert strings in hex format?
Write a php script to get the largest key in an array?
Can age be a variable?
What are the design patterns in php?
Does php require a web server?
What is the use of dual table in mysql?
How to find a substring from a given string in php?
How can you retrieve a cookie value?
Do you know what is the difference between the include() and require() functions?
How do I escape in php?
How to retrieve values out of an array?
Can we use session in mvc?
How do I repair phpmyadmin?
What is the best php framework 2018?
write a note on Testing the web site