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 is mysql_fetch_row?
Explain what is smarty?
What does $_env means?
What are the rules for naming a php variable?
What is move_uploaded_file in php?
What is mean by an associative array?
What is xss and csrf?
Is empty function c++?
What is the use of htmlspecialchars in php?
When sessions ends?
How is traits used in php?
What is difference between print and echo in php?
How to create a mysql connection in php?
Tell me how can you pass a variable by reference?
Explain what are the three classes of errors that can occur in php?