which function used to get the file name in php?
Answers were Sorted based on User's Feedback
Answer / simran
The file name on the browser system
$file_name=$_FILES[$fieldName]['name'];
| Is This Answer Correct ? | 8 Yes | 0 No |
Answer / lakshmi
<?php
$path = "/home/httpd/html/index.php";
$file = basename($path);
$file = basename($path, ".php");
?>
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / naga
$parts = Explode('/', $_SERVER["SCRIPT_NAME"]);
$currentFile = $parts[count($parts) - 1];
| Is This Answer Correct ? | 1 Yes | 1 No |
Answer / nilsoft
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"]);
| Is This Answer Correct ? | 0 Yes | 0 No |
Is php coding easy?
Is nan in javascript?
What is the use of array_count_values() in php?
How to include variables in double-quoted strings in php?
Is null or empty c#?
What is the correct and the most two common way to start and finish a php block of code?
How do you parse and process html/xml in php?
Explain what are the different errors in php?
What is the use of rand() in php?
write function of the sentence traversal passing the parameter, e.g input:this is input sentence. output:sentence input is this.
How to remove values saved in the current session?
How can i change the extension name like i have a page which name aboutme.php but i want to show it aboutme.php3 or aboutme.aspx?