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,'/').'/isu',$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_stristr($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.2.00.0000.12122.75
7.1.70.0030.12420.57
7.1.60.0130.18421.23
7.1.50.0100.17620.83
7.1.00.0070.23725.65
7.0.200.0030.11517.96
7.0.60.0030.15322.73
7.0.50.0130.16020.73
7.0.40.0070.20721.11
7.0.30.0270.15021.37
7.0.20.0300.17321.36
7.0.10.0030.15721.29
7.0.00.0230.20021.34
5.6.280.0100.16323.68
5.6.210.0030.16323.43
5.6.200.0070.23021.08
5.6.190.0070.22323.22
5.6.180.0370.16323.27
5.6.170.0270.23723.25
5.6.160.0030.16723.27
5.6.150.0100.21021.00
5.6.140.0030.16320.97
5.6.130.0130.16020.99
5.6.120.0030.15323.93
5.6.110.0030.16723.87
5.6.100.0070.15323.87
5.6.90.0130.21723.85
5.6.80.0130.20723.37
5.5.350.0430.09023.12
5.5.340.0300.05720.80
5.5.330.0200.09023.11
5.5.320.0070.09722.97
5.5.310.0300.09723.09
5.5.300.0070.05320.82
5.5.290.0130.06720.80
5.5.280.0100.06323.63
5.5.270.0030.10723.52
5.5.260.0170.04723.65
5.5.250.0030.09023.41
5.5.240.0070.09723.01
5.4.450.0570.07021.96
5.4.440.0770.11322.39
5.4.430.0100.08722.25
5.4.420.0230.07722.10
5.4.410.0330.09721.79
5.4.400.1000.09021.90
5.4.390.0870.09721.89
5.4.380.0900.09321.94
5.4.370.0970.09321.88
5.4.360.0330.08321.91
5.4.350.0100.08722.16
5.4.340.0100.09021.90
5.4.320.1000.10722.15
5.4.310.0930.11021.82
5.4.300.0930.08321.75
5.4.290.0830.07321.66
5.4.280.0200.10322.02
5.4.270.0170.08021.84
5.4.260.0570.08321.66
5.4.250.0830.09321.93
5.4.240.0800.08321.58
5.4.230.0570.10021.81
5.4.220.0270.10321.87
5.4.210.0170.07721.86
5.4.200.0800.06319.57
5.4.190.0870.06322.07
5.4.180.1100.06021.84
5.4.170.0970.10321.89
5.4.160.0870.10021.78
5.4.150.0670.07721.69
5.4.140.0770.06719.32
5.4.130.0700.06319.24
5.4.120.0700.09319.28
5.4.110.0770.06719.29
5.4.100.0930.07719.17
5.4.90.0830.07319.39
5.4.80.0630.09719.15
5.4.70.0670.07019.19
5.4.60.0570.08319.36
5.4.50.0700.07319.23
5.4.40.0870.07719.31
5.4.30.0670.08319.12
5.4.20.0730.08719.22
5.4.10.0900.07319.16
5.4.00.0870.07018.59
5.3.290.0770.08717.39
5.3.280.1000.06017.43
5.3.270.1030.08317.32
5.3.260.0830.08317.22
5.3.250.0970.06317.28
5.3.240.0900.07017.60
5.3.230.0800.09717.29
5.3.220.0930.08017.35
5.3.210.0770.08017.14
5.3.200.0770.08717.40
5.3.190.1170.07017.22
5.3.180.0970.08317.26
5.3.170.0830.08717.30
5.3.160.1000.12017.41
5.3.150.1000.07317.24
5.3.140.0770.07717.27
5.3.130.1000.06717.30
5.3.120.0770.08317.23
5.3.110.0970.07717.18
5.3.100.0770.07716.82
5.3.90.0870.07316.71
5.3.80.0870.07016.92
5.3.70.0770.07716.76
5.3.60.0200.06716.78
5.3.50.0200.08716.66
5.3.40.0400.07016.64
5.3.30.1000.10316.51
5.3.20.1130.10316.46
5.3.10.1070.06016.43
5.3.00.0130.07016.38
5.2.170.0130.06714.00
5.2.160.0630.07013.51
5.2.150.0630.07713.71
5.2.140.0600.07713.79
5.2.130.0630.07013.60
5.2.120.0630.06313.51
5.2.110.0470.07713.67
5.2.100.0670.07313.42
5.2.90.0130.07713.53
5.2.80.0030.07013.45
5.2.70.0730.07713.44
5.2.60.0830.06013.40
5.2.50.0800.08013.64
5.2.40.0800.05713.63
5.2.30.0530.08013.40
5.2.20.0500.09313.58
5.2.10.0730.07013.19
5.2.00.0570.10713.06
5.1.60.0400.07713.33
5.1.50.0670.11013.26
5.1.40.0170.09013.36
5.1.30.0100.06713.79
5.1.20.0100.06313.73
5.1.10.0070.07713.46
5.1.00.0570.07313.40
5.0.50.0400.08312.02
5.0.40.0370.10011.90
5.0.30.0100.08011.79
5.0.20.0000.07011.56
5.0.10.0200.05311.72
5.0.00.0130.08011.52
4.4.90.0030.0609.46
4.4.80.0030.0809.38
4.4.70.0430.0739.36
4.4.60.0200.0639.39
4.4.50.0270.0809.53
4.4.40.0230.0739.46
4.4.30.0370.0679.40
4.4.20.0270.0539.43
4.4.10.0230.0579.50
4.4.00.0270.0679.48
4.3.110.0200.0679.29
4.3.100.0200.0839.46
4.3.90.0200.0609.26
4.3.80.0230.0739.30
4.3.70.0270.0709.36
4.3.60.0200.0679.36
4.3.50.0330.0609.34
4.3.40.0270.0679.30
4.3.30.0070.0638.02
4.3.20.0100.1208.52
4.3.10.0200.1108.56
4.3.00.0130.1078.52

preferences:
29.59 ms | 401 KiB | 5 Q