Page 1 of 1
Getting path name of included script
Posted: Wed Sep 08, 2004 1:36 am
by bradles
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
Posted: Wed Sep 08, 2004 1:42 am
by feyd
__FILE__
Posted: Wed Sep 08, 2004 1:54 am
by bradles
__FILE__
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.
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";
I'm wondering if I should just make it a setting that the user can change in the script rather than trying to do it dynamically.
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
Posted: Wed Sep 08, 2004 2:50 am
by jakobdoppler
this is not tested , but it works somehow like this
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 );
?>
?>
*hth* _yak