WordPress开发者和主题制作者的搜索引擎



is_serialized_string ›

Since2.0.5
已弃用n/a
is_serialized_string ( $data )
参数:
  • (string) $data Serialized data.
    Required: Yes
返回:
  • (bool) False if not a serialized string, true if it is.
定义在:
文档:

Check whether serialized data is of string type.



源码

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