[thelist] PHP file_put_contents help

Pringle, Ron RPringle at aurora-il.org
Tue Jan 23 13:17:11 CST 2007


Ken Snyder wrote:


Pringle, Ron wrote:
[...]
> file_put_contents($filename,fopen($weatherdata, "rb"), LOCK_EX);
>   
[...]

fopen returns a resource, and file_put_contents accepts a string in the 
second parameter.  Try something like this:

file_put_contents($filename,file_get_contents($weatherdata));


http://php.net/fopen
http://php.net/file_put_contents
http://php.net/file_get_contents


-- Ken

Ken-

Since fopen  binds the resource to a stream and file_put_contents can accept a stream (as of 5.1.0) as the data, I'm guessing thats why the current live server version of my code works.

I'll try out using file_get_contents as well once I've resolved the permissions issue.

Thanks!

Ron



More information about the thelist mailing list