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


Please Help Members By Posting Answers For Below Questions

How can we execute a php script using command line?

528


What is a php trait?

493


What is session cookies php?

548


How to assigning a new character in a string using php?

544


What is var_dump?

585






Which array function checks if the particular key exists in the array?

498


What are different types of Print Functions available in PHP?

530


How to access a Static Member of a Class in PHP?

516


When are you supposed to use endif to end the conditional statement?

539


Does mysql need php?

456


Explain soundex() and metaphone().

578


Php program to generate fibonacci series?

551


What is api used for?

489


Write a program to get second highest number in an array using php?

532


What is null value in php?

571