|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-08-21 05:14 UTC] cpuidle at gmx dot de
Description: ------------ I'm using serialize to write array structures to the filesystem. After reading the structure again, unserialize fails to decode and returns 0 instead. Serialized sample data is included. The problem is fixed when the two larger data blocks are removed and replaced with samething without linebreaks- not sure if that's part of the problem. Reproduce code: --------------- http://www.cpuidle.de/serialized.txt PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
This is the code to save and restore the data: function download($url, $local){ $resp = fetchHTTP($url); $writefile = @fopen($local, "wb"); if(!$writefile) return false; if(!fwrite($writefile, $resp[data], strlen($resp[data]))) return false; fclose($writefile); return true; } function getHTTPcache($url){ $cfile='../videodb/cache/imdb/'.md5($url); $resp = unserialize(join('',file($cfile))); return $resp; }I'm sorry. The function where the file is written is obviously not download, but this one: function saveHTTPcache($url,$resp){ $cfile='cache/imdb/'.md5($url); $string=serialize($resp); @fwrite(@fopen("$cfile", "w"),$string,strlen($string)); }The filereading hint was a good suggestion- it does actually seem to work if I'm using file_get_contents instead of join('',file($file))- could smdb. explain why? Kindly, Andi