maybe_unserialize()对数据进行反序列化(如果数据已经被序列化)

目录

描述

译文

对数据进行反序列化(如果数据已经被序列化)

原文

Unserialize value only if it was serialized.

maybe_unserialize() 描述

用法

<?php maybe_unserialize$original ?>

maybe_unserialize() 用法

参数

$original

(string) (必填) Maybe unserialized original, if is needed.

默认值: None

maybe_unserialize() 参数

返回值

(mixed

Unserialized data can be any type.

maybe_unserialize() 返回值

注意

  • 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.

maybe_unserialize() 注意

历史

添加于 版本: 2.0.0

maybe_unserialize() 历史

源文件

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

/* ----------------------------------
 * wordpress之魂 © http://wphun.com
 * ---------------------------------- */
/**
 * Unserialize value only if it was serialized.
 *
 * @since 2.0.0
 *
 * @param string $original Maybe unserialized original, if is needed.
 * @return mixed Unserialized data can be any type.
 */
function maybe_unserialize( $original ) {
	if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in
		return @unserialize( $original );
	return $original;
}

maybe_unserialize() 源文件