File_get_contents doesn't work, then works?

file_get_contents did not work as of last night when I was doing some programming - allow_url_fopen was turned off in php.ini.

Today when I login and try, it works just fine, however allow_url_fopen is still turned off.

This doesn’t make any sense to me, does it to you?

I read through the wiki and it said file_get_contents is unsafe blah blah “use curl”, which I did. However, I believe that may be pulling double/triple duty on the bandwidth because it’s downloading from a a dreamhost directory via url (http://www.myurl.com/mydir/myfile.ext) because as far as I know you can’t use relative paths in curl. So dreamhost would be downloading from itself, and then uploading to the user.

If you are trying to open something local, use fopen(). You only need to use cURL for anything external (or more specifically, anything with “http://” and similar protocols).


si-blog | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]

Yeah. What I still don’t understand though is why file_get_contents, or fopen() would not work one day and then would start working the next day.

According to phpinfo(), php.ini allow_url_fopen hasn’t changed since yesterday so I’m trying to figure out what did.

I want to begin using file_get_contents or fopen(), but not if I don’t know why it would work one day and not the next.

In other words, I want to understand why it began working so if it stops working in the future I’m not sitting here stumped.

As long as you use the right tool for the job, what does it matter?


si-blog | Keystone Websites
Save $97 on yearly plans with promo code [color=#CC0000]SCJESSEY97[/color]

Why does it matter if something doesn’t work one day and does the next, nothing I know of has changed, and I don’t know why?

Do I really have to explain that?

Look more closely at your code; the difference is likely to be that in one instance you described a “file” via a server path while in the other you used a url. The “http:” is the clue. :wink:

–rlparker