note 80641 added to function.pathinfo
| From: | davidblinco at gmail dot com | Date: | Sat, 26 Jan 2008 15:27:30 +0000 |
| Subject: | note 80641 added to function.pathinfo | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-135429@lists.php.net to get a copy of this message | ||
This function is not perfect, but you can use it to convert a relative path to a URL.
Please email me if you can make any improvements.
<?php
function mapURL($relPath) {
$filePathName = realpath($relPath);
$filePath = realpath(dirname($relPath));
$basePath = realpath($_SERVER['DOCUMENT_ROOT']);
// can not create URL for directory lower than DOCUMENT_ROOT
if (strlen($basePath) > strlen($filePath)) {
return '';
}
return 'http://' . $_SERVER['HTTP_HOST'] .
substr($filePathName, strlen($basePath));
}
?>
----
Server IP: 91.196.196.241
Probable Submitter: 77.123.125.165
----
Manual Page -- http://www.php.net/manual/en/function.pathinfo.php
Edit -- https://master.php.net/note/edit/80641
Del: integrated -- https://master.php.net/note/delete/80641/integrated
Del: useless -- https://master.php.net/note/delete/80641/useless
Del: bad code -- https://master.php.net/note/delete/80641/bad+code
Del: spam -- https://master.php.net/note/delete/80641/spam
Del: non-english -- https://master.php.net/note/delete/80641/non-english
Del: in docs -- https://master.php.net/note/delete/80641/in+docs
Del: other reasons-- https://master.php.net/note/delete/80641
Reject -- https://master.php.net/note/reject/80641
Search -- https://master.php.net/manage/user-notes.php