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
Which of the data type is compound datatype supported by PHP?
How to count all the lines of code in a directory and sub folder?
Are react hooks stable?
Why we use get in php?
What do you mean by core php?
Explain how you can update memcached when you make changes to php?
What is difference between rest and http?
I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what is the problem?
Is learning php easy?
What type of headers that PHP supports?
How do you identify independent and dependent variables in research?
What does namespace mean in php?
How to remove the new line character from the end of a text line in php?
What are the differences between GET and POST methods in form submitting?
What are new features in php 7?