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
What does type casting mean in php? Explain with an example?
Which functions are used to count the total number of array elements in php?
What is use of count() function in php?
How to open a file in php?
What is php and how do you use it?
What is the role of php?
Is ruby on rails php?
What is the major php security hole? How to avoid?
How check field is empty or not in php?
Is jquery better than javascript?
What is sticky form in php?
What is the difference between super () and this ()?
Is multiple inheritance supported in php?
How is it possible to cast types in php?
What is the difference between php and java?