homepage Welcome to WebmasterWorld Guest from 54.211.47.170
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
$ SERVER function for file name
whatson




msg:4457243
 7:24 am on May 24, 2012 (gmt 0)

If you have mydomain.com/category/page.php

$_SERVER['SCRIPT_FILENAME'] gives you category/page.php

But is there something that gives you just page.php

If not how do you edit category/page.php or whatever it may be, e.g. category1/category2/page.php so it becomes only page.php?

 

whatson




msg:4457268
 8:22 am on May 24, 2012 (gmt 0)

sorry worked it out:
$path = $_SERVER['SCRIPT_NAME'];
$newpath = basename($path);
$arr = explode(".", $newpath);

Is that the best way?

coopster




msg:4460630
 11:05 pm on Jun 1, 2012 (gmt 0)

basename is what I would have suggested. There are optional parameters you can pass to the function as well, possibly saving you additional programming steps.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved