Friday, February 18, 2011

Get Current File Name using PHP

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

<?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]);
?>

6 comments:

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

Soc Cute said...

With a Hotmail account, you can send and receive emails quickly and easily as well as login and use all Microsoft services.
hotmail login | sign in to hotmail | recover hotmail password
This is the game so players feel very fierce , adventurous . You try to join and play this game , you will feel great like.
strike force heroes | strike force heroes 4
happy wheels | tank trouble 2 | slitherio
gun mayhem 2 | age of war | can your pet

Post a Comment