Share it

Bookmark and Share

Translate

Tuesday, May 31, 2011

0 How to get the current script running name of the file in PHP

We can get the current file name or the file executing the code by using SCRIPT_NAME. This will give us the path from the server root so the name of the current directory will also be included. Here is the code. 
Example:
If you want to get the last PHP script name from the following path
Path: /my_file/test.php 
Then we can use the following code 
Code.
$file = $_SERVER["SCRIPT_NAME"];
$break = Explode('/', $file);
$pfile = $break[count($break) - 1];
echo $pfile; 
Output: test.php

0 comments:

Post a Comment

Thanks for your valuable Comment

 

TechnoTipworld- Tips,Tricks,Technology Copyright © 2011 - |- Template created by O Pregador - |- Powered by Blogger Templates