which function used to get the file name in php?

Answers were Sorted based on User's Feedback



which function used to get the file name in php?..

Answer / simran

The file name on the browser system
$file_name=$_FILES[$fieldName]['name'];

Is This Answer Correct ?    8 Yes 0 No

which function used to get the file name in php?..

Answer / lakshmi

<?php
$path = "/home/httpd/html/index.php";
$file = basename($path);
$file = basename($path, ".php");
?>

Is This Answer Correct ?    4 Yes 0 No

which function used to get the file name in php?..

Answer / naga

$parts = Explode('/', $_SERVER["SCRIPT_NAME"]);
$currentFile = $parts[count($parts) - 1];

Is This Answer Correct ?    1 Yes 1 No

which function used to get the file name in php?..

Answer / jaimin desai

$file_name=$_FILES[$ControlName]['name'];

Is This Answer Correct ?    0 Yes 0 No

which function used to get the file name in php?..

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

Post New Answer

More PHP Interview Questions

What is the difference between public, protected and private?

1 Answers  


What is variable function php?

1 Answers  


What does the array operator '===' means?

1 Answers  


Whhat is a Functions

1 Answers   IQ,


What is the basic function to search files for lines (or other units of text) that contain a pattern.

1 Answers  


How session manage in wordpress

1 Answers   HCL, ITBS, TCS,


What is session and Cokkies . How it works . tell some thing about Session_id()

1 Answers   DVS, Net Solution, PVWEBCO,


What are the special characters you need to escape in single-quoted stings?

1 Answers  


How can MYSQL functions be available with PHP?

1 Answers  


Are static variables final?

1 Answers  


What is use of echo in php?

1 Answers  


what is variable scope, which variables are accessible from where and what are "undefined variable" errors?

1 Answers  


Categories