Advertisements

is_serialized_string

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

Advertisements

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: