-
-
Save fritids/4b378e374238c0fd507f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL); | |
$data = array(); | |
$data[] = serialize( array( 1, 2, 3, array( 'een', 'twee', 'tree' ) ) ); | |
$data[] = 'a:4:{i:0;i:1;i:1;i:2;i:2;i:3;i:3;a:3:{i:0;s:3:"een";i:1;s:4:"twee";i:2;s:4:"tree";}}'; | |
$data[] = 'a:{i0;i1;i1;i2;i2;i3;i3;a:{i0;s:"een";i1;s:"twee";i2;s:"tree";}}'; | |
$data[] = serialize( 'blah' ); | |
$data[] = 'blah'; | |
var_dump( $data ); | |
$unserialized_data = array(); | |
$unserialized_data = array_map( 'is_serialized', $data ); | |
var_dump( $unserialized_data ); | |
var_dump( is_serialized( $data[0], TRUE ) ); | |
var_dump( is_serialized( $data[2], TRUE ) ); | |
function is_serialized( $object, $just_test = FALSE ){ | |
$unserial = @unserialize( $object ); | |
if( ! $just_test ){ | |
return $unserial ? $unserial : 'No serialized data'; | |
} else { | |
return (bool) $unserial; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment