Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


How can I get the only name of the current executing file?

Answers were Sorted based on User's Feedback



How can I get the only name of the current executing file?..

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

How can I get the only name of the current executing file?..

Answer / sudeb mandal

<?php
//To get current file name.
$file = $_SERVER["SCRIPT_NAME"];
echo $file;

?>

Is This Answer Correct ?    5 Yes 1 No

How can I get the only name of the current executing file?..

Answer / palaniraja.wordpress.com

echo end(explode('/',$_SERVER["SCRIPT_NAME"]));

Is This Answer Correct ?    2 Yes 0 No

How can I get the only name of the current executing file?..

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

How can I get the only name of the current executing file?..

Answer / bhawani

$name=basename($_SERVER['PHP_SELF']);

echo $name;

Is This Answer Correct ?    0 Yes 0 No

How can I get the only name of the current executing file?..

Answer / vaishali

basename($_SERVER('PHP_SELF'));


give the current file name

Is This Answer Correct ?    2 Yes 3 No

Post New Answer

More PHP Interview Questions

What are the data types in php?

0 Answers  


Which function would you use to merge two arrays in php?

0 Answers  


What are the different errors in php?

0 Answers  


How to apply Cake php ajax pagination?

1 Answers  


What is php in full?

0 Answers  


Does php use html?

0 Answers  


What is laracast?

0 Answers  


What are major variables in research?

0 Answers  


What does $_server mean?

0 Answers  


What is variable and data type?

0 Answers  


Why triggers are used in mysql?

0 Answers  


How can we know that a session is started or not?

3 Answers   Rushmore Consultancy,


Categories