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

Write syntax to open a file in php?

516


What are the string functions in php?

518


Who is the father or inventor of php?

579


What the limitation of header() function in php?

504


What is the use of mysql_fetch_assoc in php?

510






What is the difference between file_get_contents() and file_put_contents() in php?

675


How to replace a substring in a given string in php?

546


What does the expression exception::__tostring means?

558


What is the difference between explode() and split() functions?

496


What is cURL in PHP?

546


Is php an api?

532


What is mysqli_query?

509


Could we start a variable with number like $4name?

509


What are php parameters?

522


Is jquery better than javascript?

556