I have a script that will be included on an index page but I need to get the name of the path that the particular script resides in. $_SERVER['PHP_SELF'] will give me the path name of the index.php script but the included script resides in another folder.
Any ideas about how to get that pathname? I've searched high & low and can't seem to find anything on it.
Brad
Getting path name of included script
Moderator: General Moderators
Thanks feyd, but that returns a drive path. I'm trying to get the server path to the included script because that script will be loading images. Please don't think that I don't appreciate your help. Most of what I've achieved with this project has been through your help.__FILE__
Image gallery script is in /www/weddings/
thumbnails are in /www/weddings/thumbnails/
Index script is in /www/
When the index script runs it includes the gallery script. As an example, on that script I need to show:
Code: Select all
"<img src="WWW/WEDDINGS/THUMBNAILS/IMAGE/><br>\n";It'd be nice if i had something that returns only the name of the current folder of the included file. i.e, \weddings rather than the whole path.
Brad
-
jakobdoppler
- Forum Commoner
- Posts: 46
- Joined: Wed May 21, 2003 6:16 pm
this is not tested , but it works somehow like this
*hth* _yak
Code: Select all
<?php
<?php
//to get the directory name (e.g) /www/weddings/
$path = dirname(__FILE__);
// to get the last subdirname "weddings"
$path = substr(strrchr($path,"/"), 1 );
?>
?>