3v4l.org

run code in 300+ PHP versions simultaneously
<?php function is_serialized( $data, $strict = true ) { // if it isn't a string, it isn't serialized. if ( ! is_string( $data ) ) { return false; } $data = trim( $data ); if ( 'N;' == $data ) { return true; } if ( strlen( $data ) < 4 ) { return false; } if ( ':' !== $data[1] ) { return false; } if ( $strict ) { $lastc = substr( $data, -1 ); if ( ';' !== $lastc && '}' !== $lastc ) { return false; } } else { $semicolon = strpos( $data, ';' ); $brace = strpos( $data, '}' ); // Either ; or } must exist. if ( false === $semicolon && false === $brace ) return false; // But neither must be in the first X characters. if ( false !== $semicolon && $semicolon < 3 ) return false; if ( false !== $brace && $brace < 4 ) return false; } $token = $data[0]; switch ( $token ) { case 's' : if ( $strict ) { if ( '"' !== substr( $data, -2, 1 ) ) { return false; } } elseif ( false === strpos( $data, '"' ) ) { return false; } // or else fall through case 'a' : case 'O' : return (bool) preg_match( "/^{$token}:[0-9]+:/s", $data ); case 'b' : case 'i' : case 'd' : $end = $strict ? '$' : ''; return (bool) preg_match( "/^{$token}:[0-9.E-]+;$end/", $data ); } return false; } $str = 's:4:"test"xxx'; if (is_serialized($str, false)) echo 'fuck'; else echo 'haha'; if (is_serialized($str)) echo 'haha'; else echo 'fuck';

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
5.4.340.0080.03512.04
5.4.320.0050.03512.54
5.4.310.0070.03712.53
5.4.300.0070.03412.54
5.4.290.0030.04012.53
5.4.280.0080.03412.43
5.4.270.0070.04612.43
5.4.260.0080.03812.43
5.4.250.0090.04312.43
5.4.240.0120.03412.43
5.4.230.0090.03412.42
5.4.220.0080.03812.42
5.4.210.0080.03712.42
5.4.200.0060.03712.42
5.4.190.0060.04212.41
5.4.180.0040.03912.41
5.4.170.0110.03212.42
5.4.160.0120.03212.41
5.4.150.0060.03612.41
5.4.140.0080.03912.10
5.4.130.0020.03912.09
5.4.120.0050.03612.05
5.4.110.0050.03512.05
5.4.100.0060.03512.04
5.4.90.0070.03512.04
5.4.80.0080.03412.05
5.4.70.0060.03412.04
5.4.60.0060.03612.04
5.4.50.0060.03412.04
5.4.40.0070.03312.03
5.4.30.0090.03112.03
5.4.20.0050.03512.02
5.4.10.0050.03412.03
5.4.00.0050.03611.52
5.3.290.0090.03512.80
5.3.280.0110.03612.71
5.3.270.0100.03812.72
5.3.260.0050.03912.72
5.3.250.0080.03512.72
5.3.240.0070.03612.72
5.3.230.0060.03712.70
5.3.220.0090.03312.68
5.3.210.0050.03912.68
5.3.200.0050.03712.68
5.3.190.0060.03712.67
5.3.180.0050.03612.68
5.3.170.0050.03712.67
5.3.160.0050.03612.68
5.3.150.0070.03512.67
5.3.140.0080.03412.66
5.3.130.0030.04212.66
5.3.120.0060.03812.66
5.3.110.0040.04012.66
5.3.100.0050.04312.14
5.3.90.0030.03912.12
5.3.80.0040.03812.11
5.3.70.0050.03712.11
5.3.60.0030.03812.10
5.3.50.0040.03812.04
5.3.40.0060.04712.04
5.3.30.0060.03312.00
5.3.20.0030.03711.78
5.3.10.0060.03811.75
5.3.00.0060.03511.74
5.2.170.0030.0339.24
5.2.160.0070.0279.23
5.2.150.0020.0379.24
5.2.140.0040.0309.24
5.2.130.0060.0279.20
5.2.120.0030.0299.20
5.2.110.0050.0289.20
5.2.100.0060.0369.20
5.2.90.0050.0289.20
5.2.80.0070.0329.20
5.2.70.0050.0369.20
5.2.60.0080.0259.15
5.2.50.0040.0309.13
5.2.40.0050.0309.10
5.2.30.0050.0299.07
5.2.20.0040.0289.05
5.2.10.0060.0288.96
5.2.00.0050.0288.83
5.1.60.0020.0318.11
5.1.50.0040.0258.11
5.1.40.0030.0258.09
5.1.30.0040.0298.44
5.1.20.0040.0268.46
5.1.10.0020.0278.20
5.1.00.0040.0258.20
5.0.50.0040.0196.67
5.0.40.0020.0216.54
5.0.30.0030.0316.34
5.0.20.0030.0196.30
5.0.10.0020.0216.29
5.0.00.0020.0316.28
4.4.90.0010.0164.78
4.4.80.0030.0144.75
4.4.70.0030.0144.75
4.4.60.0040.0174.75
4.4.50.0030.0174.77
4.4.40.0020.0264.71
4.4.30.0010.0174.75
4.4.20.0040.0154.85
4.4.10.0020.0164.85
4.4.00.0020.0254.76
4.3.110.0020.0164.67
4.3.100.0010.0174.66
4.3.90.0020.0154.64
4.3.80.0040.0224.58
4.3.70.0020.0154.63
4.3.60.0010.0154.63
4.3.50.0020.0154.62
4.3.40.0030.0234.53
4.3.30.0010.0163.34
4.3.20.0010.0163.32
4.3.10.0020.0163.27
4.3.00.0200.0206.85

preferences:
146.35 ms | 1394 KiB | 7 Q