maybe_serialize()必要时序列化数据

目录

描述

译文

必要时序列化数据

原文

Serialize data, if needed.

maybe_serialize() 描述

用法

<?php maybe_serialize$data ); ?>

maybe_serialize() 用法

参数

$data

(mixed) (必填) Data that might be serialized.

默认值: None

maybe_serialize() 参数

返回值

(mixed) 

A scalar data

maybe_serialize() 返回值

示例

maybe_serialize() 示例

注意

  • 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.
  • Confusingly, strings that contain already serialized values are serialized again, resulting in a nested serialization. Other strings are unmodified.

A possible solution to prevent nested serialization is to check if a variable is serialized using
<?php if(!is_serialized$data )) { $data maybe_serialize($data); } ?>


More info at is_serialized().

maybe_serialize() 注意

历史

添加于 版本: 2.0.5

maybe_serialize() 历史

源文件

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

maybe_serialize() 源文件

相关