PHP offers a way to store arrays and objects through serialization. The problem is, there is no actual PHP function the check if data is serialized. I came up with a dirty little function to help with that:
1 2 3 4 | function is_serial($data) { return (@unserialize($data) !== false); } |
unserialize will return FALSE if you pass a value that is not serialized, BUT, it will also throw an E_NOTICE error at the same time. To get around that, I add the suppressor (@) and then I attempt to unserialize the data.
Post a comment
Hello guest, care to post a comment?