Definition:
function is_serialized_string( $data ) {}
Check whether serialized data is of string type.
Parameters
- mixed $data: Serialized data
Return values
returns:False if not a serialized string, true if it is.
Source code
function is_serialized_string( $data ) {
// if it isn't a string, it isn't a serialized string
if ( !is_string( $data ) )
return false;
$data = trim( $data );
$length = strlen( $data );
if ( $length < 4 )
return false;
elseif ( ':' !== $data[1] )
return false;
elseif ( ';' !== $data[$length-1] )
return false;
elseif ( $data[0] !== 's' )
return false;
elseif ( '"' !== $data[$length-2] )
return false;
else
return true;
}
2179

February 12, 2011 


No comments yet... Be the first to leave a reply!