wpseek.com
Un motore di ricerca WordPress per sviluppatori e autori di temi



is_serialized_string › WordPress Function

Da2.0.5
Deprecaton/a
is_serialized_string ( $data )
Parametri:
  • (string) $data Serialized data.
    Richiesto:
Ritorna:
  • (bool) False if not a serialized string, true if it is.
Definito a:
Codex:

Checks whether serialized data is of string type.



Sorgenti

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