I needed a way to detect if some values were serialized or not, annoyingly PHP does not provide a method for this. I’d also rather not perform unserialize() on everything to check for a serialized string in the name of efficiency, so instead I came up with a simple function to detect serialized data. The result of my endeavours is a function that checks a string for basic makers of the PHP serialization form, it only checks the variables type and not any deeper values inside arrays or objects, if this preliminary testing is successful then unserialize() is invoked to provide the final proof. The unserialized form is available as an option argument passed by reference and the return value is a boolean, true for boolean or false otherwise. You can find the function on Gist or below.
Disclaimer
All content on this site are my own thoughts and opinions not those of my employer or projects I contribute to.
Archives
- Months
- December 2009 (2)
- October 2009 (2)
- September 2009 (1)
- July 2009 (1)
- June 2009 (1)
- May 2009 (1)
- April 2009 (2)
- March 2009 (4)
- February 2009 (1)
- January 2009 (3)
- December 2008 (3)
- November 2008 (5)
- Years
- Months