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 query string php?
What is == and === in php?
Does php have multiple inheritance?
Give the case where we can use get and we can use post methods?
Tell us how can we display the output directly to the browser?
What is php mainly used for?
Is php good for career?
What is the capacity of mysql database?
What is string in php?
How to assigning a new character in a string?
How to specify argument default values?
Write a php script to get the largest key in an array?
How do you trim spaces in excel?
What is composer json?
How to get a total number of rows available in the table?