3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Stripper{ var $regex; var $stripped; var $decoded; var $current_encoding; var $result; function __construct(){ mb_internal_encoding('UTF-8'); //mb_regex_encoding("UTF-8"); setlocale(LC_ALL, 'de_DE@euro', 'de_DE', 'deu_deu'); } private function to_utf8( $string ) { // From http://w3.org/International/questions/qa-forms-utf-8.html if ( preg_match('%^(?: [\x09\x0A\x0D\x20-\x7E] # ASCII | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | \xF0[\x90-\xBF][\x80-\xBF]{2} # planes 1-3 | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )*$%xs', $string) ) { return $string; } else { return iconv( 'CP1252', 'UTF-8', $string); } } function convert($string, $targetEncoding = 'UTF-8'){ $current_encoding = mb_detect_encoding($string); if($current_encoding != $targetEncoding){ $string = mb_convert_encoding($string, $targetEncoding, mb_detect_encoding($string)); } $result = $string; return $result; } //this function returns characters, whitespace, underscores and linebreaks plus @ , and - function strip($string){ //$this->convert($string); $result = mb_ereg_replace("[^[:word:][:alnum:][:blank:][:space:]@,\-\.]*", "", $string); return $result; } //this function returns $digits of number and discards everything else function onlyNumbers($string, $digits=0){ //$this->convert($string); $result = mb_ereg_replace("[^\d]*", "", $string); if($digits > 0){ $result = substr($result, 0, $digits); } return $result; } function decode($string, $type="all"){ //$this->convert($string); if($type == "all" || $type == "strip"){ $string = stripslashes($string); } if ($type == "all" || $type == "decode"){ $string = urldecode($string); } $result = $string; return $result; } } //mb_detect_order ( mb_internal_encoding('UTF-8'); mb_http_output('UTF-8'); mb_http_input('UTF-8'); mb_language('uni'); mb_regex_encoding('UTF-8'); ob_start('mb_output_handler'); //var_dump(mb_regex_encoding()); //var_dump( mb_get_info()); $value = "Häslïchëräëÿüïöáéüúíóßñµç.,_-;()''\"\" "; //$value = $stripper->decode($value); //$value = $stripper->convert($value); echo "before strip :" . mb_detect_encoding($value) . " for $value<br />"; //$_POST[$key] = $purifier->purify($_POST[$key]); //$value = str_replace("ß","ss",$value); $stripper = new Stripper(); $value = $stripper->strip($value); echo "after strip :". mb_detect_encoding($value) . " for $value<br />"; //phpinfo();

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)
8.3.60.0060.00918.43
8.3.50.0080.01122.05
8.3.40.0070.00718.96
8.3.30.0060.00919.07
8.3.20.0070.00020.35
8.3.10.0050.00321.79
8.3.00.0090.00017.90
8.2.180.0150.00616.63
8.2.170.0100.00722.96
8.2.160.0100.00322.26
8.2.150.0050.00224.18
8.2.140.0080.00024.66
8.2.130.0030.00526.16
8.2.120.0000.00921.16
8.2.110.0060.00321.95
8.2.100.0080.00318.16
8.2.90.0000.00819.22
8.2.80.0040.00417.97
8.2.70.0000.00817.63
8.2.60.0030.00617.77
8.2.50.0000.00918.07
8.2.40.0000.00818.22
8.2.30.0050.00317.91
8.2.20.0060.00317.61
8.2.10.0070.00018.05
8.2.00.0000.00817.79
8.1.280.0120.00625.92
8.1.270.0040.00423.97
8.1.260.0060.00326.35
8.1.250.0030.00528.09
8.1.240.0070.00321.99
8.1.230.0080.00419.18
8.1.220.0080.00017.74
8.1.210.0080.00018.77
8.1.200.0000.00917.23
8.1.190.0040.00417.13
8.1.180.0080.00018.10
8.1.170.0050.00318.49
8.1.160.0050.00222.03
8.1.150.0000.00818.71
8.1.140.0000.00817.36
8.1.130.0070.00017.81
8.1.120.0030.00517.29
8.1.110.0000.00817.36
8.1.100.0070.00317.34
8.1.90.0070.00417.34
8.1.80.0000.00717.41
8.1.70.0030.00317.25
8.1.60.0040.00417.46
8.1.50.0050.00317.48
8.1.40.0080.00417.46
8.1.30.0040.00417.60
8.1.20.0000.00817.61
8.1.10.0070.00017.51
8.1.00.0040.00417.34
8.0.300.0000.00718.77
8.0.290.0080.00016.75
8.0.280.0040.00418.44
8.0.270.0070.00017.19
8.0.260.0000.00617.19
8.0.250.0030.00317.04
8.0.240.0030.00616.95
8.0.230.0070.00016.91
8.0.220.0030.00316.84
8.0.210.0000.00716.85
8.0.200.0040.00417.00
8.0.190.0050.00316.95
8.0.180.0000.00817.01
8.0.170.0040.00416.95
8.0.160.0080.00016.90
8.0.150.0000.00716.86
8.0.140.0000.00716.86
8.0.130.0070.00013.35
8.0.120.0000.00816.93
8.0.110.0000.00716.95
8.0.100.0040.00416.98
8.0.90.0000.00816.93
8.0.80.0090.00616.92
8.0.70.0070.00016.90
8.0.60.0020.00516.94
8.0.50.0080.00017.00
8.0.30.0070.01517.13
8.0.20.0120.00917.40
8.0.10.0070.00016.87
8.0.00.0110.00716.71
7.4.330.0020.00215.71
7.4.320.0030.00317.14
7.4.300.0040.00417.17
7.4.290.0030.00517.04
7.4.280.0050.00517.11
7.4.270.0000.00717.16
7.4.260.0070.00017.14
7.4.250.0070.00017.14
7.4.240.0030.00517.13
7.4.230.0090.00016.93
7.4.220.0210.00917.19
7.4.210.0060.00917.16
7.4.200.0030.00517.14
7.4.160.0130.00317.06
7.4.150.0140.00817.40
7.4.140.0110.00617.86
7.4.130.0120.00817.08
7.4.120.0050.01217.00
7.4.110.0060.01217.00
7.4.100.0100.01417.31
7.4.90.0070.01017.13
7.4.80.0000.02419.39
7.4.70.0100.01216.79
7.4.60.0120.01316.91
7.4.50.0120.00216.94
7.4.40.0140.00516.91
7.4.30.0110.02016.61
7.4.20.0230.00016.90
7.4.10.0180.00316.80
7.4.00.0120.00616.08
7.3.330.0050.00013.68
7.3.320.0060.00013.77
7.3.310.0070.00016.89
7.3.300.0040.00416.80
7.3.290.0100.01016.78
7.3.280.0060.01316.89
7.3.270.0130.00417.40
7.3.260.0130.01016.87
7.3.240.0100.01017.00
7.3.230.0100.01017.03
7.3.210.0100.01017.14
7.3.200.0140.00416.97
7.3.190.0130.00917.05
7.3.180.0150.00816.84
7.3.170.0130.01316.89
7.3.160.0120.00916.90
7.3.150.0170.00716.54
7.3.140.0140.01016.79
7.3.130.0120.00816.79
7.3.120.0120.00615.79
7.3.110.0150.01016.46
7.3.100.0130.01016.80
7.3.90.0120.00916.74
7.3.80.0230.00316.80
7.3.70.0190.00316.62
7.3.60.0190.00616.80
7.3.50.0180.00916.58
7.3.40.0220.00616.74
7.3.30.0120.01516.76
7.3.20.0330.01016.78
7.3.10.0260.00016.53
7.3.00.0230.00016.63
7.2.330.0090.00917.21
7.2.320.0040.01417.36
7.2.310.0070.01416.94
7.2.300.0120.00917.12
7.2.290.0160.00717.18
7.2.280.0140.01416.99
7.2.270.0160.00916.86
7.2.260.0120.01216.87
7.2.250.0160.00916.84
7.2.240.0110.01116.88
7.2.230.0120.01616.79
7.2.220.0200.00616.91
7.2.210.0130.01317.00
7.2.200.0200.01616.94
7.2.190.0220.00416.88
7.2.180.0160.00616.91
7.2.170.0170.00816.97
7.2.160.0200.00316.99
7.2.150.0080.01316.88
7.2.140.0170.00716.77
7.2.130.0130.00716.80
7.2.120.0130.01116.79
7.2.110.0160.00616.89
7.2.100.1120.00416.86
7.2.90.0170.00316.65
7.2.80.1040.01416.86
7.2.70.0300.01116.98
7.2.60.0100.00916.89
7.2.50.0130.01116.90
7.2.40.0140.00817.10
7.2.30.0090.00917.04
7.2.20.0140.00816.90
7.2.10.0200.00716.87
7.2.00.0130.00617.03
7.1.330.0180.00915.70
7.1.320.0140.00715.77
7.1.310.0140.01016.05
7.1.300.0160.00815.79
7.1.290.0210.00215.88
7.1.280.0160.00915.64
7.1.270.0150.00616.01
7.1.260.0140.01115.74
7.1.250.0220.00616.09
7.1.240.0170.00715.89
7.1.230.0160.00815.88
7.1.220.0080.01015.79
7.1.210.0130.00715.88
7.1.200.0170.00715.79
7.1.190.0050.01315.71
7.1.180.0100.01015.90
7.1.170.0340.01015.87
7.1.160.0140.01115.74
7.1.150.0130.00715.74
7.1.140.0250.00715.92
7.1.130.0080.01015.90
7.1.120.0150.00415.85
7.1.110.0110.00716.01
7.1.100.0170.00816.58
7.1.90.0110.01015.81
7.1.80.0160.00615.79
7.1.70.0140.00716.36
7.1.60.0130.01216.96
7.1.50.0140.01116.24
7.1.40.0130.01116.22
7.1.30.0190.00716.17
7.1.20.0200.00616.12
7.1.10.0130.01016.00
7.1.00.0070.03118.08
7.0.330.0120.01015.54
7.0.320.0080.01715.50
7.0.310.0100.00915.61
7.0.300.0250.01215.46
7.0.290.0120.00715.49
7.0.280.0140.00715.56
7.0.270.0130.00615.69
7.0.260.0240.00815.57
7.0.250.0140.00715.60
7.0.240.0110.01115.75
7.0.230.0240.00815.61
7.0.220.0130.00715.84
7.0.210.0150.01515.60
7.0.200.0140.00716.07
7.0.190.0150.00815.78
7.0.180.0220.01215.73
7.0.170.0180.00515.67
7.0.160.0170.00515.81
7.0.150.0170.00415.73
7.0.140.0090.03017.61
7.0.130.0190.00115.78
7.0.120.0090.00915.69
7.0.110.0140.00815.53
7.0.100.0160.00715.63
7.0.90.0110.00815.61
7.0.80.0170.00715.59
7.0.70.0120.01215.66
7.0.60.0090.03417.00
7.0.50.0370.02616.31
7.0.40.0150.01916.49
7.0.30.0180.03216.50
7.0.20.0260.01816.50
7.0.10.0100.03716.52
7.0.00.0090.02616.44
5.6.400.0210.00415.93
5.6.390.0130.01315.86
5.6.380.0150.01015.29
5.6.370.0120.00915.22
5.6.360.0120.00915.24
5.6.350.0120.01115.03
5.6.340.0130.01015.18
5.6.330.0160.00515.25
5.6.320.0140.00615.34
5.6.310.0140.01015.32
5.6.300.0170.00615.08
5.6.290.0080.01215.07
5.6.280.0110.02917.02
5.6.270.0140.00815.19
5.6.260.0150.00515.36
5.6.250.0150.00715.16
5.6.240.0140.00915.17
5.6.230.0110.01015.31
5.6.220.0160.00915.34
5.6.210.0100.02417.03
5.6.200.0120.03616.35
5.6.190.0100.02017.06
5.6.180.1440.02217.04
5.6.170.0130.02016.88
5.6.160.0120.03517.12
5.6.150.0140.02016.22
5.6.140.0100.02816.12
5.6.130.0110.02916.28
5.6.120.0140.01817.23
5.6.110.0140.03017.16
5.6.100.0130.03117.35
5.6.90.0100.03817.16
5.6.80.0130.02116.94
5.6.70.1090.02017.12
5.6.60.0150.00715.12
5.6.50.0090.01215.39
5.6.40.0150.00315.13
5.6.30.0120.01115.06
5.6.20.0140.01015.41
5.6.10.0160.00715.22
5.6.00.0160.00915.20
5.5.380.0170.00614.67
5.5.370.0140.01114.54
5.5.360.0160.01114.64
5.5.350.0150.03016.47
5.5.340.0130.02115.83
5.5.330.0130.02316.45
5.5.320.1270.02116.51
5.5.310.0250.02816.56
5.5.300.0130.03315.71
5.5.290.0100.02515.74
5.5.280.0170.02316.65
5.5.270.0120.03316.61
5.5.260.0120.02516.69
5.5.250.0110.02516.57
5.5.240.0130.02416.48
5.5.230.0110.01614.49
5.5.220.0170.01014.61
5.5.210.0160.00714.50
5.5.200.0110.01314.58
5.5.190.0120.01114.52
5.5.180.0170.00614.44
5.5.170.0170.00715.40
5.5.160.0130.01014.54
5.5.150.0130.00814.60
5.5.140.0190.00614.54
5.5.130.0170.00514.55
5.5.120.0130.00814.53
5.5.110.0180.00514.54
5.5.100.0120.01014.55
5.5.90.0160.00714.39
5.5.80.0140.01014.60
5.5.70.0150.00614.48
5.5.60.0170.00614.44
5.5.50.0110.00914.64
5.5.40.0110.01514.52
5.5.30.0130.01014.56
5.5.20.0170.01014.47
5.5.10.0190.00514.55
5.5.00.0160.00814.49
5.4.450.0220.01415.08
5.4.440.0220.02015.00
5.4.430.0200.01815.23
5.4.420.0160.01715.17
5.4.410.0250.02015.06
5.4.400.0200.01415.10
5.4.390.0270.01715.03
5.4.380.0110.02314.81
5.4.370.0160.02614.83
5.4.360.0160.02114.84
5.4.350.0130.02314.84
5.4.340.0180.01814.84
5.4.330.0100.00712.91
5.4.320.0120.01812.82
5.4.310.0100.01712.82
5.4.300.0120.01612.80
5.4.290.0110.01612.83
5.4.280.0100.01812.76
5.4.270.0100.01712.85
5.4.260.0080.02112.75
5.4.250.0120.01812.74
5.4.240.0090.01912.73
5.4.230.0070.01812.75
5.4.220.0080.02412.83
5.4.210.0120.02012.75
5.4.200.0120.01712.83
5.4.190.0120.01712.74
5.4.180.0160.01512.73
5.4.170.0110.02312.73
5.4.160.0090.01912.78
5.4.150.0080.01912.75
5.4.140.0110.01512.69
5.4.130.0100.01712.71
5.4.120.0110.01912.71
5.4.110.0120.01712.67
5.4.100.0110.01812.64
5.4.90.0130.01712.67
5.4.80.0100.02012.62
5.4.70.0100.01812.60
5.4.60.0120.01712.61
5.4.50.0110.01612.63
5.4.40.0120.01712.63
5.4.30.0100.01812.62
5.4.20.0110.01612.66
5.4.10.0120.01912.67
5.4.00.0090.01712.42
5.3.290.0150.02013.01
5.3.280.0100.02113.06
5.3.270.0100.01913.05
5.3.260.0090.02213.06
5.3.250.0090.01712.98
5.3.240.0100.01813.06
5.3.230.0110.01913.01
5.3.220.0090.02413.00
5.3.210.0130.01512.93
5.3.200.0080.02112.93
5.3.190.0090.02312.98
5.3.180.0100.01813.05
5.3.170.0090.02112.97
5.3.160.0120.02113.05
5.3.150.0120.01713.04
5.3.140.0110.01912.94
5.3.130.0120.01813.02
5.3.120.0090.02012.94
5.3.110.0170.01512.94
5.3.100.0130.01912.80
5.3.90.0110.01712.81
5.3.80.0080.02012.79
5.3.70.0120.01612.77
5.3.60.0100.02012.90
5.3.50.0110.01812.76
5.3.40.0090.01912.75
5.3.30.0110.01512.74
5.3.20.0090.01612.70
5.3.10.0070.02112.62
5.3.00.0140.01312.66
5.2.170.0090.01411.60
5.2.160.0070.01411.55
5.2.150.0080.01511.54
5.2.140.0090.01411.57
5.2.130.0030.01911.58
5.2.120.0070.01411.54
5.2.110.0100.01511.55
5.2.100.0040.01811.65
5.2.90.0110.01311.55
5.2.80.0050.01711.53
5.2.70.0110.01511.51
5.2.60.0100.01611.50
5.2.50.0080.01411.52
5.2.40.0080.01411.50
5.2.30.0120.01411.56
5.2.20.0070.01411.47
5.2.10.0070.01611.43
5.2.00.0110.01411.35
5.1.60.0070.01310.95
5.1.50.0080.01110.94
5.1.40.0090.01110.99
5.1.30.0090.01211.07
5.1.20.0090.01211.06
5.1.10.0100.01110.97
5.1.00.0080.01110.96
5.0.50.0030.01210.47
5.0.40.0080.00810.42
5.0.30.0050.01510.36
5.0.20.0060.01110.34
5.0.10.0060.01010.34
5.0.00.0090.01210.33
4.4.90.0060.0069.82
4.4.80.0050.0069.82
4.4.70.0060.0069.82
4.4.60.0050.0069.81
4.4.50.0060.0069.82
4.4.40.0030.0129.80
4.4.30.0050.0079.82
4.4.20.0030.0099.85
4.4.10.0070.0069.85
4.4.00.0050.0109.81
4.3.110.0040.0089.79
4.3.100.0060.0069.79
4.3.90.0060.0069.78
4.3.80.0040.0129.76
4.3.70.0030.0089.77
4.3.60.0030.0099.77
4.3.50.0050.0099.77
4.3.40.0040.0119.74
4.3.30.0040.0089.33
4.3.20.0030.0099.33
4.3.10.0030.0079.31
4.3.00.0080.00513.32

preferences:
55.17 ms | 401 KiB | 5 Q