Re: file_get_contents ($file) works -- file_get_contents ($url) returns false

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A very typical problem. Good you sent the error message.

This problem can be caused due to one of the following-

1. I have faced similar problem due to local firewall settings.
2. Try some other domain; i.e. other than google com. Try some of the local
area website with a particular page like www.somedomain.com/somefile.html
3. Some times the remote host does not allow you to connect to get the file
contents.
4. # 3 can be either way round from both the ends a) you host server does
not allow external connections b) Remote host does not allow anonymous
connection.

Hope this helps..

Gaurav Kumar
blog.oswebstudio.com



On Thu, Dec 10, 2009 at 9:01 PM, René Fournier <m5@xxxxxxxxxxxxxxxx> wrote:

> I thought error_reporting would display them, but I guess php.ini had them
> suppressed. Anyway, with:
>
> <?php
>
> error_reporting(-1);
> ini_set('display_errors', 1);
> set_time_limit(0);
> var_dump (file_get_contents ('http://www.google.com'));
>
> ?>
>
> I get:
>
> Warning: file_get_contents(http://www.google.com): failed to open stream:
> Operation now in progress in /____/____.php on line 7 bool(false)
>
> Does that help with the diagnosis?
>
>
> On 2009-12-10, at 12:28 AM, Richard Quadling wrote:
>
> > 2009/12/9 René Fournier <m5@xxxxxxxxxxxxxxxx>:
> >> It is, and I use curl elsewhere in the same script to fetch remote
> content.
> >> This exact same function works fine on my MacBook Pro (10.6 client, PHP
> 5.3), and *was* previously working fine under Server 10.4.11 and PHP 5.3,
> >>
> >> On 2009-12-09, at 11:10 PM, laruence wrote:
> >>
> >>> try
> >>> wget http://www.google.com in your command line to see whether the
> network is reachable
> >>>
> >>> LinuxManMikeC wrote:
> >>>>
> >>>> On Wed, Dec 9, 2009 at 8:02 AM, LinuxManMikeC <
> linuxmanmikec@xxxxxxxxx> wrote:
> >>>>
> >>>>> On Wed, Dec 9, 2009 at 6:45 AM, René Fournier <m5@xxxxxxxxxxxxxxxx>
> wrote:
> >>>>>
> >>>>>> Strange problem I'm having on Mac OS X Server 10.6 running PHP 5.3.
> Any call of file_get_contents() on a local file works fine -- the file is
> read and returned. But any call of file_get_contents on a url -- any url,
> local or remote -- always returns false.
> >>>>>>
> >>>>>> var_dump (file_get_contents ('http://www.google.com/')<http://www.google.com/%27%29>
> );
> >>>>>>
> >>>>>> bool(false)
> >>>>>>
> >>>>>> I've checked php.ini, and the obvious seems okay:
> >>>>>>
> >>>>>>        allow_url_fopen => On => On
> >>>>>>
> >>>>>> Any ideas?
> >>>>>>
> >>>>>> ...Rene
> >>>>>>
> >>>>>
> http://us2.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
> >>>>>
> >>>>>
> >>>>
> >>>> "I've checked php.ini"
> >>>> Right, must remember not to reply to stuff till I'm awake. :-D
> >>>>
> >>>> --
> >>>> PHP General Mailing List (http://www.php.net/)
> >>>> To unsubscribe, visit: http://www.php.net/unsub.php
> >>>>
> >>>>
> >>>
> >>> --
> >>> <2866791487_dbbbdddf9e.jpg>惠 新宸 xinchen.hui | 商务搜索部 |
> (+8610)82602112-7974 | <2866349865_203e53a6c6.jpg>:laruence
> >>
> >>
> >
> > Do you have ANY errors/warning/notices?
> >
> >
> >
> > --
> > -----
> > Richard Quadling
> > "Standing on the shoulders of some very clever giants!"
> > EE : http://www.experts-exchange.com/M_248814.html
> > Zend Certified Engineer :
> http://zend.com/zce.php?c=ZEND002498&r=213474731
> > ZOPA : http://uk.zopa.com/member/RQuadling
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux