php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13974 file functions fail without trailing slash on urls with only the domain
Submitted: 2001-11-07 06:45 UTC Modified: 2001-11-09 05:44 UTC
From: pgl at instinct dot org Assigned:
Status: Closed Package: Filesystem function related
PHP Version: 4.0.6 OS: FreeBSD 4.3
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: pgl at instinct dot org
New email:
PHP Version: OS:

 

 [2001-11-07 06:45 UTC] pgl at instinct dot org
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-08 13:06 UTC] derick@php.net
This should be fixed, can you try a snapshot from snaps.php.net and report back wheter it works or not?

Derick
 [2001-11-09 05:44 UTC] pgl at instinct dot org
works fine now:

[mini:pgl]:~ $ /usr/local/bin/php -v
4.2.0-dev
[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 
opened file

regards,

Peter Lowe.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 14:01:30 2024 UTC