php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60406 file_exists() fopen() problems with URL (http)
Submitted: 2011-11-29 10:41 UTC Modified: 2011-12-11 16:25 UTC
From: simon dot georget at gmail dot com Assigned:
Status: Not a bug Package: *General Issues
PHP Version: Irrelevant OS: ubuntu oneiric
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: simon dot georget at gmail dot com
New email:
PHP Version: OS:

 

 [2011-11-29 10:41 UTC] simon dot georget at gmail dot com
Description:
------------
I'm using the following version of PHP on ubuntu : PHP Version 5.3.6-13ubuntu3.2

and have problems checking if an url exists with both fopen() and file_exists() functions.

print_r(stream_get_wrappers()); returns :

Array ( [0] => https [1] => ftps [2] => compress.zlib [3] => compress.bzip2 [4] => php [5] => file [6] => glob [7] => data [8] => http [9] => ftp [10] => phar [11] => zip ) 

(test script is above)

Test script:
---------------
if(!file_exists('http://maps.googleapis.com/maps/api/js?sensor=false')) {
    echo 'Problem loading the url';

} else {
    echo 'it works!';
}

Expected result:
----------------
it works!

Actual result:
--------------
Problem loading the url

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-11-29 17:01 UTC] simon dot georget at gmail dot com
**Actually fopen() works correctly!!!**

if(!fopen('http://maps.googleapis.com/maps/api/js?sensor=false', 'r')) {
    echo 'Problem loading the url';

} else {
    echo 'it works!';
}

returns it works!
 [2011-11-30 02:43 UTC] reeze dot xia at gmail dot com
Hi, simon:
  @see http://docs.php.net/manual/en/wrappers.http.php
  The Options "Wrapper Summary" section the http wrapper doesn't support stat()
  and file_exists() rely on that. http stream wrapper support fopen.
  file_exits() dones't support all the enabled stream wrappers.
  You can visit http://cn2.php.net/manual/en/wrappers.php for a full supported 
streams.

thanks.
 [2011-11-30 09:35 UTC] simon dot georget at gmail dot com
-Status: Open +Status: Closed
 [2011-11-30 09:35 UTC] simon dot georget at gmail dot com
Hi reeze,

Many thanks for your reply. It's clear.
Sorry for the inadapted bug report. Close it now.
 [2011-12-11 16:25 UTC] cataphract@php.net
-Status: Closed +Status: Bogus
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 05 22:01:29 2024 UTC