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 can we execute a php script using command line?
What is a php trait?
What is session cookies php?
How to assigning a new character in a string using php?
What is var_dump?
Which array function checks if the particular key exists in the array?
What are different types of Print Functions available in PHP?
How to access a Static Member of a Class in PHP?
When are you supposed to use endif to end the conditional statement?
Does mysql need php?
Explain soundex() and metaphone().
Php program to generate fibonacci series?
What is api used for?
Write a program to get second highest number in an array using php?
What is null value in php?