is_serialized

函数


is_serialized ( $data, $strict = true )
参数
  • (string)
    $data
    Value to check to see if was serialized.
    Required:
  • (bool)
    $strict
    Optional. Whether to be strict about the end of the string. Default true.
    Required:
    Default: true
返回值
  • (bool) False if not serialized and true if it was.
定义位置
  • wp-includes/functions.php
    , line 670
引入
2.0.5
弃用

Checks value to find if it was serialized.

If $data is not a string, then returned value will always be false.
Serialized data is always a string.

function is_serialized( $data, $strict = true ) {
	// If it isn't a string, it isn't serialized.
	if ( ! is_string( $data ) ) {
		return false;
	}
	$data = trim( $data );
	if ( 'N;' === $data ) {
		return true;
	}
	if ( strlen( $data )