A blog by a system administrator and programmer.

file_get_contents getting mad? 
Tuesday, April 20, 2010, 08:20 PM - Programming
Posted by Freddy Chu
My blog is died for awhile after php upgrade to 5.2.13. It is full of error about putting a non-array into rsort.

The root cause of the problem is due to the this blog store entries in file base, some of the file listing is serialized array. If you copy those content and try to unserialize it, it is perfect no error.

It really make me shocked as i expected the problem is come from serialization algorithm but it is not. It really cost me some time to figure out that the problem is from file_get_contents. It is really tricky, it won't show on command line mode but only happens in php modules of apache.

The REAL reason of unserializable is because file_get_contents add slashes into the output string. I have really no idea why i happens...

So I use the most DIRTY way to fix that ... add a stripslashes after call file_get_contents.

If anybody know the reasons please let me know :(


573 comments ( 3010 views )   |  permalink   |   ( 3 / 5859 )

<Back | 1 | 2 | Next> Last>>