maybe_unserialize() WP 1.0
Unserialize value only if it was serialized.
1 time = 0.000047s = very fast | 50000 times = 1.21s = fast | PHP 7.1.2, WP 4.7.4
No Hooks.
Return
Mixed. Unserialized data can be any type.
Usage
maybe_unserialize( $data );
- $data(string) (required)
- Data that might be unserialized.
Changelog
Since 2.0.0 | Introduced. |
Code of maybe_unserialize() maybe unserialize WP 5.6
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;
}Related Functions
From tag: serialize
More from category: Helper Functions
- __return_empty_array()
- __return_empty_string()
- __return_false()
- __return_null()
- __return_true()
- __return_zero()
- build_query()
- get_page_hierarchy()
- get_temp_dir()
- human_readable_duration()
- is_email()
- is_php_version_compatible()
- is_wp_version_compatible()
- map_deep()
- path_join()
- seems_utf8()
- stripslashes_deep()
- timer_stop()
- urlencode_deep()
- wp_array_slice_assoc()
- wp_basename()
- wp_debug_backtrace_summary()
- wp_doing_ajax()
- wp_extract_urls()
- wp_filter_object_list()
- wp_generate_uuid4()
- wp_html_split()
- wp_is_json_request()
- wp_is_numeric_array()
- wp_is_uuid()
- wp_json_encode()
- wp_kses_array_lc()
- wp_kses_hair()
- wp_kses_uri_attributes()
- wp_list_filter()
- wp_list_pluck()
- wp_list_sort()
- wp_make_link_relative()