3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $examples = array( 'Valid ASCII' => array("a", true), 'Valid 2 Octet Sequence' => array("\xc3\xb1", true), 'Invalid 2 Octet Sequence' => array("\xc3\x28", false), 'Invalid Sequence Identifier' => array("\xa0\xa1", false), 'Valid 3 Octet Sequence' => array("\xe2\x82\xa1", true), 'Invalid 3 Octet Sequence (in 2nd Octet)' => array("\xe2\x28\xa1", false), 'Invalid 3 Octet Sequence (in 3rd Octet)' => array("\xe2\x82\x28", false), 'Valid 4 Octet Sequence' => array("\xf0\x90\x8c\xbc", true), 'Invalid 4 Octet Sequence (in 2nd Octet)' => array("\xf0\x28\x8c\xbc", false), 'Invalid 4 Octet Sequence (in 3rd Octet)' => array("\xf0\x90\x28\xbc", false), 'Invalid 4 Octet Sequence (in 4th Octet)' => array("\xf0\x28\x8c\x28", false), 'Valid 5 Octet Sequence (but not Unicode!)' => array("\xf8\xa1\xa1\xa1\xa1", false), 'Valid 6 Octet Sequence (but not Unicode!)' => array("\xfc\xa1\xa1\xa1\xa1\xa1", false), ); function checkWithPreg($str) { return preg_match('//u', $str); } function checkWithMbstring($str) { return mb_check_encoding($str, 'UTF-8'); } function runTests($method, $count) { global $examples; $start_m = microtime(); $start = time(); for($i=0; $i<$count; $i++) { foreach($examples as $title => $arr) { list($str, $bool) = $arr; $method($str); } } $end_m = microtime(); $end = time(); $bench = ($end - $start) + ($end_m - $start_m); echo "$method $bench\n"; } runTests('checkWithMbstring', 10000); runTests('checkWithPreg', 10000);
Output for 7.1.0
Notice: A non well formed numeric value encountered in /in/XGV7W on line 33 Notice: A non well formed numeric value encountered in /in/XGV7W on line 33 checkWithMbstring 0.098399 Notice: A non well formed numeric value encountered in /in/XGV7W on line 33 Notice: A non well formed numeric value encountered in /in/XGV7W on line 33 checkWithPreg -0.028661
Output for 7.0.14
checkWithMbstring 0.049032 checkWithPreg -0.0255
Output for 7.0.10
checkWithMbstring 0.09118 checkWithPreg 0.032694
Output for 7.0.9
checkWithMbstring 0.096328 checkWithPreg 0.032484
Output for 7.0.8
checkWithMbstring 0.106971 checkWithPreg 0.034946
Output for 7.0.7
checkWithMbstring 0.085425 checkWithPreg 0.033916
Output for 7.0.6
checkWithMbstring 0.110485 checkWithPreg 0.03354
Output for 7.0.5
checkWithMbstring 0.08072 checkWithPreg 0.030051
Output for 7.0.4
checkWithMbstring 0.080346 checkWithPreg 0.03222
Output for 7.0.3
checkWithMbstring 0.080715 checkWithPreg 0.032811
Output for 7.0.2
checkWithMbstring 0.080251 checkWithPreg 0.032705
Output for 7.0.1
checkWithMbstring 0.08307 checkWithPreg 0.03244
Output for 7.0.0
checkWithMbstring 0.082082 checkWithPreg 0.033183
Output for 5.6.28
checkWithMbstring -0.011586 checkWithPreg -0.060308
Output for 5.6.25
checkWithMbstring 0.10784 checkWithPreg 0.065729
Output for 5.6.24
checkWithMbstring 0.127816 checkWithPreg 0.066922
Output for 5.6.23
checkWithMbstring 0.124563 checkWithPreg 0.077839
Output for 5.6.22
checkWithMbstring 0.084432 checkWithPreg 0.054306
Output for 5.6.21
checkWithMbstring 0.112642 checkWithPreg 0.067033
Output for 5.6.20
checkWithMbstring 0.10592 checkWithPreg 0.067677
Output for 5.6.19
checkWithMbstring 0.103127 checkWithPreg 0.065177
Output for 5.6.18
checkWithMbstring 0.107374 checkWithPreg 0.067596
Output for 5.6.17
checkWithMbstring 0.105907 checkWithPreg 0.068181
Output for 5.6.16
checkWithMbstring 0.123457 checkWithPreg 0.070564
Output for 5.6.15
checkWithMbstring 0.136271 checkWithPreg 0.067575
Output for 5.6.14
checkWithMbstring 0.115473 checkWithPreg 0.065095
Output for 5.6.13
checkWithMbstring 0.115157 checkWithPreg 0.066589
Output for 5.6.12
checkWithMbstring 0.107402 checkWithPreg 0.06711
Output for 5.6.11
checkWithMbstring 0.132919 checkWithPreg 0.065655
Output for 5.6.10
checkWithMbstring 0.111874 checkWithPreg 0.066487
Output for 5.6.9
checkWithMbstring 0.110673 checkWithPreg 0.066477
Output for 5.6.8
checkWithMbstring 0.117722 checkWithPreg 0.065996
Output for 5.6.7
checkWithMbstring 0.117743 checkWithPreg 0.069249
Output for 5.6.6
checkWithMbstring 0.112846 checkWithPreg 0.068628
Output for 5.6.5
checkWithMbstring 0.125977 checkWithPreg 0.081089
Output for 5.6.4
checkWithMbstring 0.125082 checkWithPreg 0.066914
Output for 5.6.3
checkWithMbstring 0.125683 checkWithPreg 0.065187
Output for 5.6.2
checkWithMbstring 0.13981 checkWithPreg 0.067713
Output for 5.6.1
checkWithMbstring 0.137 checkWithPreg 0.067685
Output for 5.6.0
checkWithMbstring 0.112071 checkWithPreg 0.065306
Output for 5.5.38
checkWithMbstring 0.136181 checkWithPreg 0.071326
Output for 5.5.37
checkWithMbstring 0.118707 checkWithPreg 0.070726
Output for 5.5.36
checkWithMbstring 0.109941 checkWithPreg 0.070525
Output for 5.5.35
checkWithMbstring 0.113688 checkWithPreg 0.069979
Output for 5.5.34
checkWithMbstring 0.147859 checkWithPreg 0.075379
Output for 5.5.33
checkWithMbstring 0.113033 checkWithPreg 0.072525
Output for 5.5.32
checkWithMbstring 0.119061 checkWithPreg 0.071425
Output for 5.5.31
checkWithMbstring 0.139836 checkWithPreg 0.071335
Output for 5.5.30
checkWithMbstring 0.136471 checkWithPreg 0.0715
Output for 5.5.29
checkWithMbstring 0.109441 checkWithPreg 0.073638
Output for 5.5.28
checkWithMbstring 0.120034 checkWithPreg 0.071929
Output for 5.5.27
checkWithMbstring 0.118615 checkWithPreg 0.065354
Output for 5.5.26
checkWithMbstring 0.112519 checkWithPreg 0.068269
Output for 5.5.25
checkWithMbstring 0.116278 checkWithPreg 0.070948
Output for 5.5.24
checkWithMbstring 0.135147 checkWithPreg 0.07216
Output for 5.5.23
checkWithMbstring 0.131028 checkWithPreg 0.073986
Output for 5.5.22
checkWithMbstring 0.146706 checkWithPreg 0.082119
Output for 5.5.21
checkWithMbstring 0.135358 checkWithPreg 0.070495
Output for 5.5.20
checkWithMbstring 0.14675 checkWithPreg 0.071088
Output for 5.5.19
checkWithMbstring 0.117039 checkWithPreg 0.070422
Output for 5.5.18
checkWithMbstring 0.103709 checkWithPreg 0.068263
Output for 5.5.16
checkWithMbstring 0.125531 checkWithPreg 0.071264
Output for 5.5.15
checkWithMbstring 0.125963 checkWithPreg 0.070237
Output for 5.5.14
checkWithMbstring 0.119777 checkWithPreg 0.071659
Output for 5.5.13
checkWithMbstring 0.129776 checkWithPreg 0.071371
Output for 5.5.12
checkWithMbstring 0.117108 checkWithPreg 0.07086
Output for 5.5.11
checkWithMbstring 0.140589 checkWithPreg 0.069998
Output for 5.5.10
checkWithMbstring 0.129484 checkWithPreg 0.071794
Output for 5.5.9
checkWithMbstring 0.110747 checkWithPreg 0.070241
Output for 5.5.8
checkWithMbstring 0.139519 checkWithPreg 0.07113
Output for 5.5.7
checkWithMbstring 0.139618 checkWithPreg 0.070734
Output for 5.5.6
checkWithMbstring 0.126153 checkWithPreg 0.070341
Output for 5.5.5
checkWithMbstring 0.115691 checkWithPreg 0.071485
Output for 5.5.4
checkWithMbstring 0.134202 checkWithPreg 0.083629
Output for 5.5.3
checkWithMbstring 0.126093 checkWithPreg 0.072107
Output for 5.5.2
checkWithMbstring 0.145258 checkWithPreg 0.095143
Output for 5.5.1
checkWithMbstring 0.173821 checkWithPreg 0.07057
Output for 5.5.0
checkWithMbstring 0.133512 checkWithPreg 0.070383
Output for 5.4.45
checkWithMbstring 0.141322 checkWithPreg 0.069691
Output for 5.4.44
checkWithMbstring 0.132405 checkWithPreg 0.070262
Output for 5.4.43
checkWithMbstring 0.117977 checkWithPreg 0.070563
Output for 5.4.42
checkWithMbstring 0.134094 checkWithPreg 0.063129
Output for 5.4.41
checkWithMbstring 0.132594 checkWithPreg 0.072749
Output for 5.4.40
checkWithMbstring 0.139726 checkWithPreg 0.070285
Output for 5.4.39
checkWithMbstring 0.129956 checkWithPreg 0.069894
Output for 5.4.38
checkWithMbstring 0.112078 checkWithPreg 0.069661
Output for 5.4.37
checkWithMbstring 0.139515 checkWithPreg 0.072416
Output for 5.4.36
checkWithMbstring 0.134735 checkWithPreg 0.081558
Output for 5.4.35
checkWithMbstring 0.112845 checkWithPreg 0.071241
Output for 5.4.34
checkWithMbstring 0.11822 checkWithPreg 0.070617
Output for 5.4.32
checkWithMbstring 0.13837 checkWithPreg 0.070312
Output for 5.4.31
checkWithMbstring 0.148333 checkWithPreg 0.07115
Output for 5.4.30
checkWithMbstring 0.114314 checkWithPreg 0.070577
Output for 5.4.29
checkWithMbstring 0.118801 checkWithPreg 0.070614
Output for 5.4.28
checkWithMbstring 0.12098 checkWithPreg 0.071142
Output for 5.4.27
checkWithMbstring 0.132151 checkWithPreg 0.084387
Output for 5.4.26
checkWithMbstring 0.150133 checkWithPreg 0.081619
Output for 5.4.25
checkWithMbstring 0.145546 checkWithPreg 0.071059
Output for 5.4.24
checkWithMbstring 0.143614 checkWithPreg 0.080779
Output for 5.4.23
checkWithMbstring 0.119266 checkWithPreg 0.070646
Output for 5.4.22
checkWithMbstring 0.124003 checkWithPreg 0.069876
Output for 5.4.21
checkWithMbstring 0.14022 checkWithPreg 0.075045
Output for 5.4.20
checkWithMbstring 0.150506 checkWithPreg 0.07752
Output for 5.4.19
checkWithMbstring 0.147951 checkWithPreg 0.070694
Output for 5.4.18
checkWithMbstring 0.137855 checkWithPreg 0.070901
Output for 5.4.17
checkWithMbstring 0.11998 checkWithPreg 0.071616
Output for 5.4.16
checkWithMbstring 0.150993 checkWithPreg 0.070247
Output for 5.4.15
checkWithMbstring 0.137784 checkWithPreg 0.068606
Output for 5.4.14
checkWithMbstring 0.13314 checkWithPreg 0.07841
Output for 5.4.13
checkWithMbstring 0.133619 checkWithPreg 0.073624
Output for 5.4.12
checkWithMbstring 0.129417 checkWithPreg 0.069192
Output for 5.4.11
checkWithMbstring 0.112764 checkWithPreg 0.070251
Output for 5.4.10
checkWithMbstring 0.120922 checkWithPreg 0.069887
Output for 5.4.9
checkWithMbstring 0.127927 checkWithPreg 0.070419
Output for 5.4.8
checkWithMbstring 0.116034 checkWithPreg 0.072099
Output for 5.4.7
checkWithMbstring 0.125084 checkWithPreg 0.072856
Output for 5.4.6
checkWithMbstring 0.127856 checkWithPreg 0.071986
Output for 5.4.5
checkWithMbstring 0.12553 checkWithPreg 0.076823
Output for 5.4.4
checkWithMbstring 0.128611 checkWithPreg 0.070545
Output for 5.4.3
checkWithMbstring 0.138827 checkWithPreg 0.070345
Output for 5.4.2
checkWithMbstring 0.120505 checkWithPreg 0.072689
Output for 5.4.1
checkWithMbstring 0.150785 checkWithPreg 0.071624
Output for 5.4.0
checkWithMbstring 0.152845 checkWithPreg 0.075557
Output for 5.3.29
checkWithMbstring 0.128046 checkWithPreg 0.074738
Output for 5.3.28
checkWithMbstring 0.138725 checkWithPreg 0.074865
Output for 5.3.27
checkWithMbstring 0.146618 checkWithPreg 0.075937
Output for 5.3.26
checkWithMbstring 0.146364 checkWithPreg 0.08615
Output for 5.3.25
checkWithMbstring 0.16242 checkWithPreg 0.076388
Output for 5.3.24
checkWithMbstring 0.135868 checkWithPreg 0.074446
Output for 5.3.23
checkWithMbstring 0.144149 checkWithPreg 0.075079
Output for 5.3.22
checkWithMbstring 0.153162 checkWithPreg 0.08588
Output for 5.3.21
checkWithMbstring 0.135698 checkWithPreg 0.07797
Output for 5.3.20
checkWithMbstring 0.144275 checkWithPreg 0.076878
Output for 5.3.19
checkWithMbstring 0.135813 checkWithPreg 0.075013
Output for 5.3.18
checkWithMbstring 0.135338 checkWithPreg 0.087305
Output for 5.3.17
checkWithMbstring 0.131272 checkWithPreg 0.077482
Output for 5.3.16
checkWithMbstring 0.165017 checkWithPreg 0.076839
Output for 5.3.15
checkWithMbstring 0.149909 checkWithPreg 0.077288
Output for 5.3.14
checkWithMbstring 0.129991 checkWithPreg 0.078505
Output for 5.3.13
checkWithMbstring 0.157152 checkWithPreg 0.076484
Output for 5.3.12
checkWithMbstring 0.132243 checkWithPreg 0.094095
Output for 5.3.11
checkWithMbstring 0.135385 checkWithPreg 0.076306
Output for 5.3.10
checkWithMbstring 0.14376 checkWithPreg 0.079381
Output for 5.3.9
checkWithMbstring 0.140541 checkWithPreg 0.074199
Output for 5.3.8
checkWithMbstring 0.133474 checkWithPreg 0.077891
Output for 5.3.7
checkWithMbstring 0.163936 checkWithPreg 0.077377
Output for 5.3.6
checkWithMbstring 0.154601 checkWithPreg 0.078721
Output for 5.3.5
checkWithMbstring 0.140952 checkWithPreg 0.077257
Output for 5.3.4
checkWithMbstring 0.134711 checkWithPreg 0.079634
Output for 5.3.3
checkWithMbstring 0.129339 checkWithPreg 0.076915
Output for 5.3.2
checkWithMbstring 0.153474 checkWithPreg 0.075931
Output for 5.3.1
checkWithMbstring 0.126069 checkWithPreg 0.076832
Output for 5.3.0
checkWithMbstring 0.124635 checkWithPreg 0.073707
Output for 5.2.17
checkWithMbstring 0.164527 checkWithPreg 0.088952
Output for 5.2.16
checkWithMbstring 0.156846 checkWithPreg 0.08932
Output for 5.2.15
checkWithMbstring 0.14377 checkWithPreg 0.090154
Output for 5.2.14
checkWithMbstring 0.15481 checkWithPreg 0.090122
Output for 5.2.13
checkWithMbstring 0.134594 checkWithPreg 0.090645
Output for 5.2.12
checkWithMbstring 0.172204 checkWithPreg 0.092471
Output for 5.2.11
checkWithMbstring 0.165866 checkWithPreg 0.091278
Output for 5.2.10
checkWithMbstring 0.15681 checkWithPreg 0.090259
Output for 5.2.9
checkWithMbstring 0.160102 checkWithPreg 0.091398
Output for 5.2.8
checkWithMbstring 0.160952 checkWithPreg 0.089922
Output for 5.2.7
checkWithMbstring 0.155941 checkWithPreg 0.097162
Output for 5.2.6
checkWithMbstring 0.159862 checkWithPreg 0.08869
Output for 5.2.5
checkWithMbstring 0.16771 checkWithPreg 0.089626
Output for 5.2.4
checkWithMbstring 0.160003 checkWithPreg 0.091537
Output for 5.2.3
checkWithMbstring 0.143679 checkWithPreg 0.087601
Output for 5.2.2
checkWithMbstring 0.167345 checkWithPreg 0.089271
Output for 5.2.1
checkWithMbstring 0.133802 checkWithPreg 0.091982
Output for 5.2.0
checkWithMbstring 0.136799 checkWithPreg 0.094808
Output for 5.1.6
checkWithMbstring 0.177858 checkWithPreg 0.090481
Output for 5.1.5
checkWithMbstring 0.188394 checkWithPreg 0.088032
Output for 5.1.4
checkWithMbstring 0.17085 checkWithPreg 0.087294
Output for 5.1.3
checkWithMbstring 0.151311 checkWithPreg 0.085726
Output for 5.0.0 - 5.1.2
Fatal error: Call to undefined function mb_check_encoding() in /in/XGV7W on line 18
Process exited with code 255.
Output for 4.4.9
checkWithMbstring 0.216703 checkWithPreg 0.125052
Output for 4.4.8
checkWithMbstring 0.265916 checkWithPreg 0.124331
Output for 4.4.7
checkWithMbstring 0.256587 checkWithPreg 0.124609
Output for 4.4.6
checkWithMbstring 0.259621 checkWithPreg 0.126605
Output for 4.4.5
checkWithMbstring 0.251436 checkWithPreg 0.132844
Output for 4.4.4
checkWithMbstring 0.206394 checkWithPreg 0.1043
Output for 4.4.3
checkWithMbstring 0.192901 checkWithPreg 0.130774
Output for 4.3.2 - 4.4.2
Fatal error: Call to undefined function: mb_check_encoding() in /in/XGV7W on line 18
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: mb_check_encoding() in /in/XGV7W on line 18