A WordPress-centric search engine for devs and theme authors



maybe_unserialize ›

Since2.0.0
Deprecatedn/a
maybe_unserialize ( $data )
Parameters:
  • (string) $data Data that might be unserialized.
    Required: Yes
Returns:
  • (mixed) Unserialized data can be any type.
Defined at:
Codex:

Unserialize data only if it was serialized.



Source

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;
}