Bug #13974: file functions fail without trailing slash on urls with only the domain
| From: | pgl at instinct dot org | Date: | Wed, 07 Nov 2001 11:45:18 +0000 |
| Subject: | Bug #13974: file functions fail without trailing slash on urls with only the domain | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-69755@lists.php.net to get a copy of this message | ||
From: pgl@instinct.org
Operating system: FreeBSD 4.3
PHP version: 4.0.6
PHP Bug Type: Filesystem function related
Bug description: file functions fail without trailing slash on urls with only the domain
if the trailing slash is left off urls when using fopen(), file() etc, php
doesn't open the location.
eg:
[mini:pgl]:~/public_html/test $ cat fopen.php
#!/usr/local/bin/php -q
<?
$loc = 'http://www.php.net/';
if ($fp = fopen($loc, "r")) echo "opened file\n";
?>
[mini:pgl]:~/public_html/test $ ./fopen.php
opened file
but:
[mini:pgl]:~ $ cat fopen.php
#!/usr/local/bin/php -q
<?
$loc = 'http://www.php.net'; // no trailing
slash
if ($fp = fopen($loc, "r")) echo "opened file\n";
?>
[mini:pgl]:~ $ ./fopen.php
<br>
<b>Warning</b>: fopen("http://www.php.net","r") -
Undefined error: 0 in
<b>./fopen.php</b> on line <b>3</b><br>
same with file():
[mini:pgl]:~ $ cat file.php
#!/usr/local/bin/php -q
<?
$loc = 'http://www.php.net/';
echo count(file($loc));
?>
[mini:pgl]:~ $ ./file.php
531
take away the trailing slash:
[mini:pgl]:~ $ ./file.php
<br>
<b>Warning</b>: file("http://www.php.net") - Undefined error: 0 in
<b>./file.php</b> on line <b>3</b><br>
1
[mini:pgl]:~ $ /usr/local/bin/php -v
4.0.6
regards,
Peter Lowe.
--
Edit bug report at: http://bugs.php.net/?id=13974&edit=1