maybe_unserialize

Unserialize value only if it was serialized.

Description

maybe_unserialize( (string) $original ); 

Parameters (1)

0. $original (string)
Maybe unserialized original, if is needed.

Usage

  1. if ( !function_exists( 'maybe_unserialize' ) ) { 
  2. require_once ABSPATH . WPINC . '/functions.php'; 
  3.  
  4. // Maybe unserialized original, if is needed. 
  5. $original = ''; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = maybe_unserialize($original); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/functions.php  
  1. function maybe_unserialize( $original ) { 
  2. if ( is_serialized( $original ) ) // don't attempt to unserialize data that wasn't serialized going in 
  3. return @unserialize( $original ); 
  4. return $original;