Friday, February 18, 2011

Get Current File Name using PHP

There are two ways I found to get the current page name using php.

$path = $_SERVER["SCRIPT_NAME"];
$file = basename($path); // $file is set to "myfile.php"
$file = basename($path, ".php"); // $file is set to "myfile"

$currentFile = $_SERVER["SCRIPT_NAME"];
$parts = Explode('/', $currentFile);
$parts = array_reverse($parts);
echo("Script is " . $parts[0]);


Summarizer said...

Thanks for the helpful post. This is what I need!

vehicle wraps orange county said...

This is a great website post. cheers very much for the great insight and we really appreciate the time you took to write this.

CustomWriting said...

so simply!! amazing...two minutes and everithing works well again!! thanks a lot

Orange County Blind Cleaners said...

I think this computer Get Current File Name using PHP is much more effective than the other one.

Bắp Cải said...

I am an avid reader who likes engaging content. That's why I am here. Your original views on this topic are refreshing and interesting. You've done a great job of expressing your views. Thank you.
tu 95| call of duty| clicker heroes| strike force heroes 2| kitten cannon
scooby doo games| scooby doo| brain games| braingames| brain

Post a Comment