is_serialized_string( string $data )

Check whether serialized data is of string type.


Description Description


Parameters Parameters

$data

(string) (Required) Serialized data.


Top ↑

Return Return

(bool) False if not a serialized string, true if it is.


Top ↑

Source Source

File: wp-includes/functions.php

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 );
	if ( strlen( $data ) < 4 ) {
		return false;
	} elseif ( ':' !== $data[1] ) {
		return false;
	} elseif ( ';' !== substr( $data, -1 ) ) {
		return false;
	} elseif ( 's' !== $data[0] ) {
		return false;
	} elseif ( '"' !== substr( $data, -2, 1 ) ) {
		return false;
	} else {
		return true;
	}
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.0.5 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.