note 46879 added to function.file-get-contents
| From: | benatzygoatdotca at osu1 dot php dot net | Date: | Tue, 26 Oct 2004 20:52:05 +0000 |
| Subject: | note 46879 added to function.file-get-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-79139@lists.php.net to get a copy of this message | ||
The above code example:
<?php
$url = 'http://example.com/with funny chars';
list($protocol, $uri) = split('//', $url);
$html = file_get_contents($protocol . '//' . urlencode($uri));
?>
does not work. The slash trailing "example.com" will be turned into %2F, and the resolver
fails to find a host named "example.com%2F".
Did nobody test this?
I cannot immediately see a workaround, short of doing a str_replace after the urlencode to turn %2F
back into slashes. Anyone?
-ben
----
Manual Page -- http://www.php.net/manual/en/function.file-get-contents.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+46879
Delete -- http://master.php.net/manage/user-notes.php?action=delete+46879&report=yes
Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+46879&report=yes&reason=bad+code
Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+46879&report=yes&reason=spam
Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+46879&report=yes&reason=useless+example
Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+46879&report=yes&reason=contains+commercial+links
Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+46879&report=yes&reason=useless+note
Reject -- http://master.php.net/manage/user-notes.php?action=reject+46879&report=yes
Search -- http://master.php.net/manage/user-notes.php