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
Write syntax to open a file in php?
What are the string functions in php?
Who is the father or inventor of php?
What the limitation of header() function in php?
What is the use of mysql_fetch_assoc in php?
What is the difference between file_get_contents() and file_put_contents() in php?
How to replace a substring in a given string in php?
What does the expression exception::__tostring means?
What is the difference between explode() and split() functions?
What is cURL in PHP?
Is php an api?
What is mysqli_query?
Could we start a variable with number like $4name?
What are php parameters?
Is jquery better than javascript?