How can I get the only name of the current executing file?
Answers were Sorted based on User's Feedback
Answer / hitha
$file_path=$_SERVER["SCRIPT_NAME"];
$break=explode('/',$file_path);
$file_name=$break[count($break)-1];
| Is This Answer Correct ? | 12 Yes | 0 No |
Answer / sudeb mandal
<?php
//To get current file name.
$file = $_SERVER["SCRIPT_NAME"];
echo $file;
?>
| Is This Answer Correct ? | 5 Yes | 1 No |
Answer / palaniraja.wordpress.com
echo end(explode('/',$_SERVER["SCRIPT_NAME"]));
| Is This Answer Correct ? | 2 Yes | 0 No |
Answer / 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 |
Answer / bhawani
$name=basename($_SERVER['PHP_SELF']);
echo $name;
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / vaishali
basename($_SERVER('PHP_SELF'));
give the current file name
| Is This Answer Correct ? | 2 Yes | 3 No |
How to find length of an array in php ?
How can we encrypt the username and password using PHP?
13 Answers Avaria, HCL, TCS, Xpert,
Why json is used in php?
A company named Pensar Technologies in chennai has offered me a job as Software Trainee in chennai.But they are asking to pay demand draft of Rs.75000/- in the name of the company.They are saying the gross renumeration will pay Rs.90000/- annually.I want to know whether this is good or bad company?Help me out in this.
how many type of url?
How to store the uploaded file to the final location?
What are the different types of php variables?
When to use self over $this?
How to specify argument default values?
Tell me how do you execute a php script from the command line?
I am a 2007 Passed out, Jobless for almost 2.6 years. I am preparing myself as a Php programmer. Will i get a job in Php and can any one guide me please.
What is the function func_num_args() used for?