W3cubDocs

/WordPress

maybe_unserialize( string $original )

Unserialize value only if it was serialized.

Description

Parameters

$original

(string) (Required) Maybe unserialized original, if is needed.

Return

(mixed) Unserialized data can be any type.

Source

File: wp-includes/functions.php

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

Changelog

Version Description
2.0.0 Introduced.

© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/maybe_unserialize