3v4l.org

run code in 300+ PHP versions simultaneously
<?php function pcre_stristr($raw,$str,$pos=false){ $r = ''; if($raw!='' && $str!=''){ $str = (string) $str; $tmp = preg_split('/'.preg_quote($str,'/').'/su',$raw,2,PREG_SPLIT_OFFSET_CAPTURE); if(count($tmp)==2){ if($pos){ $r = $tmp[0][0]; } else{ if($tmp[0][0]==''){ $r = $raw; } else{ $r = substr($raw,strlen($tmp[0][0])); } } } else{ $r = false; } } return $r; } $raw = '0123456789abcdefghijklmnopqrstuvwxyzÁáÀàÂâÄäÃãĄąÆæÇçÉéÈèÊêËëĘęÍíÎîÌìÏïĮįÑñÓóÒòÔôÖöÕõŒœŞşẞßÚúÙùÛûÜüŲųŸÿ0123456789abcdefghijklmnopqrstuvwxyzÁáÀàÂâÄäÃãĄąÆæÇçÉéÈèÊêËëĘęÍíÎîÌìÏïĮįÑñÓóÒòÔôÖöÕõŒœŞşẞßÚúÙùÛûÜüŲųŸÿ'; $len = mb_strlen($raw); $tmp = array(); for($i=0;$i<10000;$i++){ $start = $lenth = 0; $start = mt_rand(0,$len-1); $length = mt_rand(1,min($len-$start,10)); if($start+$length<=$len){ $tmp[] = mb_substr($raw,$start,$length); } } $tmp = array_slice(array_unique($tmp),0,1000); echo '-----compatibility test-----'.PHP_EOL; echo 'samples count: '.count($tmp).PHP_EOL; foreach($tmp as $str){ $chk = true; if($chk && mb_stristr($raw,$str)!=pcre_stristr($raw,$str)){ $chk = false; } if($chk && mb_stristr($raw,$str,true)!=pcre_stristr($raw,$str,true)){ $chk = false; } if(!$chk && $str!='ß'){ echo 'raw: '.$raw.PHP_EOL; echo 'str: '.$str.PHP_EOL.PHP_EOL; echo 'mb_stristr($raw,$str,false)'.PHP_EOL.mb_stristr($raw,$str,false).PHP_EOL.PHP_EOL; echo 'pcre_stristr($raw,$str,false)'.PHP_EOL.pcre_stristr($raw,$str,false).PHP_EOL.PHP_EOL; echo 'mb_stristr($raw,$str,true)'.PHP_EOL.mb_stristr($raw,$str,true).PHP_EOL.PHP_EOL; echo 'pcre_stristr($raw,$str,true)'.PHP_EOL.pcre_stristr($raw,$str,true).PHP_EOL.PHP_EOL; echo 'test failed'; exit(); } } echo 'test finished'.PHP_EOL.PHP_EOL; echo '-----runtime test-----'.PHP_EOL; echo 'mb_stristr() x1000'.PHP_EOL; $time = microtime(true); foreach($tmp as $str){ mb_strstr($raw,$str); } $timea = microtime(true)-$time; echo 'load in '.number_format($timea,5).'ms'.PHP_EOL.PHP_EOL; echo 'pcre_stristr() x1000'.PHP_EOL; $time = microtime(true); foreach($tmp as $str){ pcre_stristr($raw,$str); } $timeb = microtime(true)-$time; echo 'load in '.number_format($timeb,5).'ms'.PHP_EOL.PHP_EOL; echo 'time save '.number_format(100-100*($timeb/$timea),2).'%'; ?>

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)
7.4.00.0170.01416.25
7.3.120.0090.01616.25
7.3.110.0080.01816.59
7.3.100.0060.02116.44
7.3.90.0080.01616.41
7.3.80.0060.01616.32
7.3.70.0020.02216.46
7.3.60.0060.01916.33
7.3.50.0030.02116.36
7.3.40.0030.02116.46
7.3.30.0070.01816.30
7.3.20.0080.01518.63
7.3.10.0120.01518.65
7.3.00.0070.01518.68
7.2.250.0100.02416.04
7.2.240.0130.01616.51
7.2.230.0050.02416.60
7.2.220.0030.02316.52
7.2.210.0090.02116.60
7.2.200.0080.01816.60
7.2.190.0050.02016.63
7.2.180.0070.01816.40
7.2.170.0110.01516.43
7.2.160.0030.02216.62
7.2.150.0050.02618.94
7.2.140.0070.01818.96
7.2.130.0050.02118.79
7.2.120.0070.02418.72
7.2.110.0050.02218.87
7.2.100.0050.02218.95
7.2.90.0080.01918.78
7.2.80.0070.01618.97
7.2.70.0090.01918.86
7.2.60.0060.02118.94
7.2.50.0070.02018.90
7.2.40.0040.02318.83
7.2.30.0070.02118.85
7.2.20.0070.01918.80
7.2.10.0020.02818.72
7.2.00.0060.02019.56
7.1.330.0080.02618.00
7.1.320.0020.03217.87
7.1.310.0020.02717.91
7.1.300.0050.02617.68
7.1.290.0060.02517.81
7.1.280.0050.03017.98
7.1.270.0040.02417.88
7.1.260.0050.02617.93
7.1.250.0080.02618.12
7.1.70.0070.03219.12
7.1.60.0100.03719.42
7.1.50.0100.03918.59
7.1.00.0100.08024.30
7.0.200.0070.02716.44
7.0.60.0030.06321.72
7.0.50.0070.07019.49
7.0.40.0070.08720.33
7.0.30.0130.05720.12
7.0.20.0270.05320.21
7.0.10.0270.09320.14
7.0.00.0070.09320.28
5.6.280.0030.05023.93
5.6.210.0100.08723.43
5.6.200.0030.06020.98
5.6.190.0130.07723.24
5.6.180.0030.11323.20
5.6.170.0170.06023.16
5.6.160.0000.10323.21
5.6.150.0100.09321.01
5.6.140.0000.07020.96
5.6.130.0130.06020.99
5.6.120.0000.07023.95
5.6.110.0170.09323.86
5.6.100.0100.11323.86
5.6.90.0100.11023.89
5.6.80.0130.07723.23
5.5.350.0030.10323.27
5.5.340.0170.05720.80
5.5.330.0200.09722.96
5.5.320.0400.09722.95
5.5.310.0330.07022.82
5.5.300.0000.07320.76
5.5.290.0030.06720.84
5.5.280.0000.05723.48
5.5.270.0130.08023.59
5.5.260.0100.10023.73
5.5.250.0130.10323.47
5.5.240.0070.08322.98
5.4.450.0630.08321.96
5.4.440.0170.09022.26
5.4.430.0130.08322.35
5.4.420.0300.07721.98
5.4.410.0270.07322.07
5.4.400.0170.07321.79
5.4.390.0170.07321.80
5.4.380.0200.07021.84
5.4.370.0200.07721.91
5.4.360.0170.08321.93
5.4.350.0330.06721.94
5.4.340.0330.06322.05
5.4.320.0370.10021.78
5.4.310.0200.07721.66
5.4.300.0200.08021.84
5.4.290.0370.05721.66
5.4.280.0200.07721.93
5.4.270.0370.05721.91
5.4.260.0230.07022.02
5.4.250.0170.08022.07
5.4.240.0300.10321.91
5.4.230.0430.09021.95
5.4.220.0230.08021.62
5.4.210.0130.07721.78
5.4.200.0170.07019.59
5.4.190.0330.10321.82
5.4.180.0200.09021.96
5.4.170.0200.08022.00
5.4.160.0170.07321.75
5.4.150.0100.08721.87
5.4.140.0270.08019.27
5.4.130.0230.07019.32
5.4.120.0100.07719.15
5.4.110.0100.07719.40
5.4.100.0200.06719.16
5.4.90.0230.06319.34
5.4.80.0230.10719.16
5.4.70.0200.06719.30
5.4.60.0230.07719.33
5.4.50.0270.07319.15
5.4.40.0130.08319.23
5.4.30.0270.07019.20
5.4.20.0200.08319.14
5.4.10.0270.07319.22
5.4.00.0200.07018.61
5.3.290.0100.09017.29
5.3.280.0230.07717.52
5.3.270.0200.08017.31
5.3.260.0330.07017.35
5.3.250.0270.07317.18
5.3.240.0170.08017.37
5.3.230.0270.06717.23
5.3.220.0170.08017.29
5.3.210.0200.11317.29
5.3.200.0270.07017.50
5.3.190.0170.08017.34
5.3.180.0230.07717.25
5.3.170.0130.08017.25
5.3.160.0230.07317.41
5.3.150.0170.07317.29
5.3.140.0070.08317.32
5.3.130.0200.08017.21
5.3.120.0230.08717.25
5.3.110.0170.10717.47
5.3.100.0400.09316.61
5.3.90.0230.07717.00
5.3.80.0070.08316.72
5.3.70.0200.08716.72
5.3.60.0130.07716.63
5.3.50.0230.07716.55
5.3.40.0170.08716.78
5.3.30.0300.09316.75
5.3.20.0200.09316.35
5.3.10.0200.10716.34
5.3.00.0130.08716.30
5.2.170.0170.06013.41
5.2.160.0200.07713.50
5.2.150.0370.05713.61
5.2.140.0130.09313.47
5.2.130.0100.06713.45
5.2.120.0270.08713.96
5.2.110.0170.10313.45
5.2.100.0270.09013.61
5.2.90.0170.07014.17
5.2.80.0130.07313.45
5.2.70.0200.07713.56
5.2.60.0130.10313.55
5.2.50.0330.08013.51
5.2.40.0200.07313.44
5.2.30.0130.06713.61
5.2.20.0130.06713.81
5.2.10.0200.07013.20
5.2.00.0070.07013.21
5.1.60.0170.06013.50
5.1.50.0200.05313.36
5.1.40.0100.07013.45
5.1.30.0100.07013.75
5.1.20.0230.06013.88
5.1.10.0130.07013.50
5.1.00.0070.07713.41
5.0.50.0030.07311.95
5.0.40.0200.05311.96
5.0.30.0070.10311.74
5.0.20.0070.07011.56
5.0.10.0100.08011.63
5.0.00.0130.08711.62
4.4.90.0130.0779.38
4.4.80.0130.0909.35
4.4.70.0170.0839.39
4.4.60.0030.0709.44
4.4.50.0100.0679.40
4.4.40.0100.0709.46
4.4.30.0070.0639.45
4.4.20.0100.0609.50
4.4.10.0130.0639.54
4.4.00.0000.0809.48
4.3.110.0200.0509.46
4.3.100.0170.0509.36
4.3.90.0070.0579.39
4.3.80.0070.0709.35
4.3.70.0070.0609.34
4.3.60.0100.0539.27
4.3.50.0200.0439.35
4.3.40.0070.0709.34
4.3.30.0070.0608.04
4.3.20.0030.1478.61
4.3.10.0070.1178.48
4.3.00.0170.1138.50

preferences:
45.57 ms | 401 KiB | 5 Q