note 14925 deleted from function.realpath by aidan
| From: | aidan@php.net | Date: | Sun, 29 Aug 2004 21:52:27 +0000 |
| Subject: | note 14925 deleted from function.realpath by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-75624@lists.php.net to get a copy of this message | ||
Note Submitter: twadzilla{at}yahoo{dot}com
----
I have PHP4 running on Win2k IIS and consequently the $DOCUMENT_ROOT is not automatically defined by
PHP. Since I often need to find the absolute path of a virtual path, I created a workaround function
that acts like server.mappath() from ASP:<br>
// relative path to virtual directory root
$relative = str_repeat('../',substr_count($PATH_INFO,'/')-1);
function mappath($path) {
// transforms virtual or relative path to an absolute path
global $relative;
return realpath(substr($path,0,1)=='/' ? $relative.substr($path,1) : $path);
}<br>
Hope this is helpful to some of you.<br>
> Dave [twadzilla.com]