note 14531 deleted from function.dirname by sniper
| From: | sniper@php.net | Date: | Mon, 09 Dec 2002 06:05:27 +0000 |
| Subject: | note 14531 deleted from function.dirname by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-40561@lists.php.net to get a copy of this message | ||
I had some problems with dirname() not properly parsing some URLS, translating for example...
"http://www.xyz.com" to "http:"
and
"http://www.xyz.com/~someuser" to
"http://www.xyz.com"
To fix, I do something like this...
$temp_dir = dirname($doc->url);
$temp_base = basename($doc->url);
$base_url = $temp_dir;
if (preg_match ("/^~[a-zA-Z0-9\-\_]*$/", $temp_base)) {
$base_url = $temp_dir . "/" . $temp_base;
}
if ($temp_dir == "http:") {
$base_url = $temp_dir . "//" . $temp_base;
}