On this page
is_serialized_string( string $data ): bool
Checks whether serialized data is of string type.
Parameters
$datastring Required-
Serialized data.
Return
bool False if not a serialized string, true if it is.
Source
File: wp-includes/functions.php. View all references
function is_serialized_string( $data ) {
// if it isn't a string, it isn't a serialized string.
if ( ! is_string( $data ) ) {
return false;
}
$data = trim( $data );
if ( strlen( $data ) < 4 ) {
return false;
} elseif ( ':' !== $data[1] ) {
return false;
} elseif ( ';' !== substr( $data, -1 ) ) {
return false;
} elseif ( 's' !== $data[0] ) {
return false;
} elseif ( '"' !== substr( $data, -2, 1 ) ) {
return false;
} else {
return true;
}
}
Related
Used By
| Used By | Description |
|---|---|
| _list_meta_row() wp-admin/includes/template.php | Outputs a single row of public meta data in the Custom Fields meta box. |
Changelog
| Version | Description |
|---|---|
| 2.0.5 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/is_serialized_string