maybe_unserialize

函式
maybe_unserialize ( $data )
引數
  • (string) $data Data that might be unserialized.
    Required:
返回值
  • (mixed) Unserialized data can be any type.
定義位置
相關方法
maybe_serializeis_serializedimage_downsizeserialize_blockget_user_locale
引入
2.0.0
棄用
-

maybe_unserialize函式用於取消WordPress中的資料序列化。如果資料已經被取消序列化,該函式將原樣返回。否則,它將使用 PHP unserialize 函式來取消資料的序列化。

只有在資料被序列化的情況下才解除序列化。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function maybe_unserialize( $data ) {
if ( is_serialized( $data ) ) { // Don't attempt to unserialize data that wasn't serialized going in.
return @unserialize( trim( $data ) );
}
return $data;
}
function maybe_unserialize( $data ) { if ( is_serialized( $data ) ) { // Don't attempt to unserialize data that wasn't serialized going in. return @unserialize( trim( $data ) ); } return $data; }
function maybe_unserialize( $data ) {
	if ( is_serialized( $data ) ) { // Don't attempt to unserialize data that wasn't serialized going in.
		return @unserialize( trim( $data ) );
	}

	return $data;
}

常見問題

FAQs
檢視更多 >