is_serialized_string()查看序列化的数据是否为字符串类型

目录

描述

译文

查看序列化的数据是否为字符串类型

原文

Check whether serialized data is of string type.

is_serialized_string() 描述

用法

<?php is_serialized_string$data ?>

is_serialized_string() 用法

参数

$data

(mixed) (必填) Serialized data

默认值: None

is_serialized_string() 参数

返回值

(boolean) 

False if not a serialized string, true if it is.

is_serialized_string() 返回值

注意

  • Data might need to be serialized to allow it to be successfully stored and retrieved from a database in a form that PHP can understand.

is_serialized_string() 注意

历史

添加于 版本: 2.0.5

is_serialized_string() 历史

源文件

is_serialized_string() 函数的代码位于 wp-includes/functions.php.

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Check whether serialized data is of string type.
 *
 * @since 2.0.5
 *
 * @param string $data Serialized data.
 * @return bool False if not a serialized string, true if it is.
 */
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;="" }="" }="">

is_serialized_string() 源文件