Some of you will find this problem, that unserialize return error on data that haven't been serialized. So this function will help to keep your code clean :
<?php
/**
* check if a data is serialized or not
*
* @param mixed $data variable to check
* @return boolean
*/
function is_serialized ( $data ){
if ( trim ( $data ) == "" ) {
return false ;
}
if ( preg_match ( "/^(i|s|a|o|d)(.*);/si" , $data )) {
return true ;
}
return false ;
}
?>
Sample :
<?php
if ( is_serialized ( $data ))
$undata = unserialize ( $data );
?>
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query Categories : PHP , PHP , HTML , PDF , Excel Objects to XML Serializer/Unserializer Categories : PHP , PHP Classes , DOM XML , Serialize Three Cool Classes and One Trick Categories : PHP , PHP Classes , Graphics , Email Get the correct extension and MIME types of an image, even when the filename is incorrect. Categories : PHP , Filesystem , General SQL COM Support in PHP Categories : PHP , COM phpMyAdmin is a free software tool written in PHP intended to handle the administration of MySQL over the World Wide Web. Categories : Databases , MySQL , Complete Programs , PHP Class TStringList include some metods from class TStringList
implemented in INPRISE/BORLAND-DELPHI Categories : PHP Classes , PHP , Strings Print out array key => value in colored HTML Categories : PHP , Arrays , HTML and PHP Get the self URL of current page Categories : PHP , URLs , Beginner Guides Selecting a random line from a text file Categories : PHP , Filesystem , Arrays , Beginner Guides CALENDAR - easy calendar-navigation with PHP Categories : PHP , Date Time , HTML and PHP , Calendar Persistent connections - General information. Categories : General SQL , PHP , Databases Simple graphic clock/watch generation using gd library. Categories : Graphics , Date Time , PHP Email a user with out exposing email address Categories : PHP , Databases , MySQL , Email Count how many weeks in the month have a specified day, such as Mon, Tue, etc. Var avail - number of days - first day name of the month, occurrences of Sun, occurrences of Mon, etc. Allows you to calculate number of working hours exclude Holidays. Categories : Calendar , Date Time , PHP , Databases , MySQL