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.70.0070.01416.75
8.3.60.0110.00418.43
8.3.50.0120.00522.05
8.3.40.0150.00018.45
8.3.30.0080.00618.95
8.3.20.0070.00020.33
8.3.10.0040.00421.80
8.3.00.0000.00817.93
8.2.180.0110.01116.36
8.2.170.0090.00622.96
8.2.160.0080.00620.43
8.2.150.0000.00824.18
8.2.140.0030.00524.66
8.2.130.0000.00826.16
8.2.120.0040.00421.04
8.2.110.0150.00622.25
8.2.100.0070.00421.12
8.2.90.0040.00419.22
8.2.80.0050.00317.97
8.2.70.0000.00817.63
8.2.60.0100.00017.80
8.2.50.0000.00818.07
8.2.40.0000.01018.09
8.2.30.0020.00517.86
8.2.20.0060.00317.64
8.2.10.0030.00518.05
8.2.00.0040.00417.80
8.1.280.0070.01125.92
8.1.270.0090.00024.02
8.1.260.0040.00426.35
8.1.250.0030.00728.09
8.1.240.0000.01018.52
8.1.230.0070.00318.92
8.1.220.0030.00617.78
8.1.210.0030.00518.77
8.1.200.0090.00017.23
8.1.190.0030.00517.10
8.1.180.0040.00418.10
8.1.170.0030.00518.48
8.1.160.0040.00422.01
8.1.150.0000.00718.78
8.1.140.0040.00417.24
8.1.130.0070.00017.84
8.1.120.0040.00417.35
8.1.110.0000.00817.33
8.1.100.0000.00817.34
8.1.90.0000.00917.35
8.1.80.0050.00317.39
8.1.70.0070.00017.25
8.1.60.0040.00417.50
8.1.50.0080.00017.49
8.1.40.0000.00917.38
8.1.30.0040.00417.60
8.1.20.0000.00817.68
8.1.10.0000.00817.52
8.1.00.0050.00317.38
8.0.300.0060.00318.77
8.0.290.0000.00716.75
8.0.280.0030.00318.30
8.0.270.0030.00317.11
8.0.260.0070.00017.14
8.0.250.0030.00317.07
8.0.240.0000.00716.99
8.0.230.0000.00717.05
8.0.220.0050.00216.92
8.0.210.0040.00416.97
8.0.200.0000.00817.07
8.0.190.0030.00316.95
8.0.180.0050.00216.95
8.0.170.0080.00016.86
8.0.160.0000.00716.88
8.0.150.0070.00016.93
8.0.140.0040.00416.82
8.0.130.0000.00613.35
8.0.120.0050.00316.88
8.0.110.0000.00716.77
8.0.100.0040.00417.00
8.0.90.0050.00216.83
8.0.80.0090.01216.93
8.0.70.0070.00017.00
8.0.60.0040.00416.98
8.0.50.0060.00316.91
8.0.30.0120.01017.00
8.0.20.0140.00617.40
8.0.10.0000.00817.02
8.0.00.0070.01116.79
7.4.330.0000.00515.72
7.4.320.0000.00717.20
7.4.300.0060.00317.19
7.4.290.0030.00617.14
7.4.280.0000.00817.11
7.4.270.0000.00717.09
7.4.260.0070.00017.13
7.4.250.0040.00417.00
7.4.240.0040.00417.15
7.4.230.0040.00416.98
7.4.220.0070.01217.28
7.4.210.0030.01017.17
7.4.200.0040.00417.07
7.4.160.0100.00617.00
7.4.150.0160.00317.40
7.4.140.0120.00517.86
7.4.130.0070.01416.98
7.4.120.0120.00517.09
7.4.110.0100.00716.90
7.4.100.0140.00617.09
7.4.90.0120.00617.09
7.4.80.0030.01819.39
7.4.70.0130.00817.03
7.4.60.0120.00817.00
7.4.50.0090.00416.79
7.4.40.0070.01316.99
7.4.30.0080.01617.20
7.4.20.0190.00616.93
7.4.10.0110.01116.01
7.4.00.0100.00815.69
7.3.330.0000.00513.89
7.3.320.0030.00313.71
7.3.310.0040.00417.07
7.3.300.0040.00416.68
7.3.290.0090.00916.86
7.3.280.0080.01016.88
7.3.270.0150.00317.40
7.3.260.0100.01016.78
7.3.240.0130.00417.17
7.3.230.0150.00616.87
7.3.210.0030.01416.72
7.3.200.0100.00716.77
7.3.190.0120.00916.86
7.3.180.0090.00917.01
7.3.170.0070.01116.93
7.3.160.0110.01016.88
7.3.150.0180.00916.83
7.3.140.0060.01816.89
7.3.130.0100.01215.94
7.3.120.0110.00815.29
7.3.110.0060.01215.64
7.3.100.0050.01015.61
7.3.90.0100.01015.64
7.3.80.0040.01015.69
7.3.70.0090.00815.62
7.3.60.0090.00615.58
7.3.50.0070.01015.46
7.3.40.0100.00715.41
7.3.30.0070.00515.48
7.3.20.0100.00816.75
7.3.10.0080.00816.71
7.3.00.0130.00616.55
7.2.330.0060.01217.00
7.2.320.0090.00817.14
7.2.310.0090.01217.24
7.2.300.0120.00917.08
7.2.290.0120.01417.07
7.2.280.0150.00717.05
7.2.270.0170.01317.13
7.2.260.0090.01516.23
7.2.250.0080.01215.66
7.2.240.0130.00615.81
7.2.230.0120.00915.66
7.2.220.0100.00815.79
7.2.210.0100.00715.81
7.2.200.0070.01215.76
7.2.190.0070.00915.77
7.2.180.0090.00415.79
7.2.170.0060.01215.80
7.2.160.0130.00516.17
7.2.150.0120.00617.11
7.2.140.0030.01717.03
7.2.130.0130.00816.93
7.2.120.0110.01016.84
7.2.110.0070.01516.83
7.2.100.0150.00816.98
7.2.90.0130.00917.03
7.2.80.0130.01217.00
7.2.70.0140.00816.98
7.2.60.0080.01116.79
7.2.50.0100.00916.66
7.2.40.0160.00616.98
7.2.30.0130.01016.90
7.2.20.0140.00916.95
7.2.10.0130.00816.98
7.2.00.0070.01117.61
7.1.330.0200.01016.05
7.1.320.0800.00916.04
7.1.310.0150.00615.90
7.1.300.0160.00315.88
7.1.290.0100.00915.88
7.1.280.0140.00615.91
7.1.270.0130.00615.98
7.1.260.0120.00815.91
7.1.250.0170.00715.84
7.1.240.0210.00616.00
7.1.230.0190.01116.04
7.1.220.0180.00916.00
7.1.210.0830.01215.97
7.1.200.0100.00916.02
7.1.190.0140.00915.99
7.1.180.0130.01016.06
7.1.170.0150.01016.02
7.1.160.0120.00916.01
7.1.150.0200.00516.01
7.1.140.0150.00615.92
7.1.130.0140.01016.08
7.1.120.0150.00915.99
7.1.110.0160.00716.01
7.1.100.0190.01216.76
7.1.90.0160.01116.15
7.1.80.0130.00916.08
7.1.70.0090.01116.52
7.1.60.0130.00917.08
7.1.50.0120.01316.47
7.1.40.0120.01015.99
7.1.30.0140.00615.80
7.1.20.0260.00515.98
7.1.10.0110.00816.10
7.1.00.0070.03418.14
7.0.330.0100.01115.44
7.0.320.0150.00815.78
7.0.310.0100.01215.69
7.0.300.0130.00815.73
7.0.290.0150.00715.63
7.0.280.0180.00715.54
7.0.270.0120.01115.72
7.0.260.0160.00815.62
7.0.250.0160.01015.70
7.0.240.0180.01115.76
7.0.230.0130.01315.70
7.0.220.0130.00915.84
7.0.210.0130.00715.72
7.0.200.0140.00816.10
7.0.190.0150.00815.62
7.0.180.0090.01115.73
7.0.170.0130.00915.73
7.0.160.0130.00615.54
7.0.150.0160.00715.65
7.0.140.0120.02817.76
7.0.130.0220.01015.77
7.0.120.0120.00715.62
7.0.110.0180.00615.68
7.0.100.0130.01115.72
7.0.90.0120.01115.77
7.0.80.0160.00715.72
7.0.70.0130.01015.50
7.0.60.0160.02417.03
7.0.50.0090.03316.50
7.0.40.0130.01816.53
7.0.30.0220.02716.57
7.0.20.0180.02416.51
7.0.10.0100.02916.55
7.0.00.0100.02016.54
5.6.400.0160.00815.60
5.6.390.0140.00515.32
5.6.380.0110.01415.46
5.6.370.0220.00515.56
5.6.360.0110.01215.41
5.6.350.0150.01015.49
5.6.340.0100.01415.46
5.6.330.0110.01315.59
5.6.320.0120.01415.39
5.6.310.0110.01515.30
5.6.300.0160.00815.50
5.6.290.0120.01015.53
5.6.280.0130.02717.24
5.6.270.0150.01015.50
5.6.260.0150.01115.64
5.6.250.0120.01115.43
5.6.240.0160.00715.44
5.6.230.0130.00915.34
5.6.220.0080.01715.54
5.6.210.0150.02317.15
5.6.200.0120.02616.32
5.6.190.0100.02417.06
5.6.180.1430.02217.29
5.6.170.0180.03217.08
5.6.160.0180.01817.06
5.6.150.0120.02416.43
5.6.140.0100.02716.47
5.6.130.0080.03716.42
5.6.120.0140.02117.27
5.6.110.0120.02517.35
5.6.100.0160.03117.28
5.6.90.0160.01917.31
5.6.80.0080.03317.08
5.6.70.0610.02117.02
5.6.60.0150.00915.49
5.6.50.0150.00915.35
5.6.40.0160.00615.35
5.6.30.0110.01315.26
5.6.20.0130.01215.40
5.6.10.0180.00815.22
5.6.00.0140.01015.37
5.5.380.0180.00715.39
5.5.370.0100.00915.38
5.5.360.0060.01615.29
5.5.350.0140.03317.09
5.5.340.0110.02116.23
5.5.330.0110.02016.92
5.5.320.1400.02117.02
5.5.310.0150.03417.04
5.5.300.0090.03716.19
5.5.290.0160.02216.19
5.5.280.0070.02517.20
5.5.270.0140.01917.05
5.5.260.0110.03617.06
5.5.250.0140.02717.18
5.5.240.0190.03116.85
5.5.230.0160.01015.32
5.5.220.0150.00815.36
5.5.210.0090.01615.09
5.5.200.0130.01215.38
5.5.190.0150.01115.33
5.5.180.0150.01015.14
5.5.170.0130.00915.31
5.5.160.0120.01015.26
5.5.150.0160.01115.35
5.5.140.0170.00815.44
5.5.130.0140.01015.18
5.5.120.0140.01015.14
5.5.110.0150.00915.33
5.5.100.0140.01015.29
5.5.90.0150.00815.08
5.5.80.0140.01015.12
5.5.70.0160.00915.46
5.5.60.0150.00715.38
5.5.50.0120.01115.29
5.5.40.0170.00315.01
5.5.30.0120.00915.33
5.5.20.0100.01515.21
5.5.10.0140.01115.17
5.5.00.0170.00615.29
5.4.450.0130.02214.67
5.4.440.0270.02714.63
5.4.430.0150.01314.75
5.4.420.0320.01814.76
5.4.410.0280.01914.61
5.4.400.0110.01914.60
5.4.390.0190.02214.61
5.4.380.0280.02914.45
5.4.370.0390.02314.41
5.4.360.0360.02214.38
5.4.350.0290.02614.42
5.4.340.0400.02414.40
5.4.330.0080.00912.23
5.4.320.0090.01612.45
5.4.310.0070.02012.30
5.4.300.0110.01912.34
5.4.290.0080.02012.39
5.4.280.0110.01712.30
5.4.270.0080.01812.29
5.4.260.0100.01712.40
5.4.250.0080.01712.29
5.4.240.0080.01912.32
5.4.230.0120.01412.36
5.4.220.0080.02112.35
5.4.210.0070.01712.34
5.4.200.0050.02012.29
5.4.190.0060.02012.34
5.4.180.0090.01812.30
5.4.170.0090.01612.39
5.4.160.0100.01712.28
5.4.150.0080.02112.32
5.4.140.0090.01612.26
5.4.130.0090.01512.19
5.4.120.0060.01912.18
5.4.110.0070.01812.21
5.4.100.0090.01612.15
5.4.90.0080.01812.17
5.4.80.0080.01812.21
5.4.70.0060.01612.20
5.4.60.0090.01612.21
5.4.50.0070.01812.26
5.4.40.0090.01512.22
5.4.30.0060.01912.20
5.4.20.0090.01612.19
5.4.10.0040.02012.26
5.4.00.0080.01712.00
5.3.290.0130.02112.34
5.3.280.0090.01712.28
5.3.270.0080.01912.36
5.3.260.0080.01812.35
5.3.250.0140.01512.36
5.3.240.0070.01812.31
5.3.230.0080.01812.33
5.3.220.0100.01612.37
5.3.210.0080.01912.32
5.3.200.0060.02012.27
5.3.190.0100.01712.35
5.3.180.0070.01912.35
5.3.170.0070.01812.33
5.3.160.0110.01812.33
5.3.150.0080.01912.39
5.3.140.0080.01712.31
5.3.130.0070.01912.36
5.3.120.0080.01612.40
5.3.110.0070.01712.37
5.3.100.0120.01612.14
5.3.90.0070.02012.15
5.3.80.0060.01912.09
5.3.70.0060.01812.09
5.3.60.0090.01412.11
5.3.50.0060.01912.06
5.3.40.0080.01712.08
5.3.30.0100.01412.06
5.3.20.0090.01712.03
5.3.10.0100.02011.95
5.3.00.0090.01611.89
5.2.170.0050.02410.56
5.2.160.0040.02210.56
5.2.150.0100.02510.56
5.2.140.0100.01810.56
5.2.130.0060.02010.54
5.2.120.0060.01910.55
5.2.110.0100.01610.54
5.2.100.0110.01710.61
5.2.90.0100.01810.55
5.2.80.0090.02010.54
5.2.70.0090.01910.54
5.2.60.0080.02210.52
5.2.50.0060.02110.50
5.2.40.0070.02010.53
5.2.30.0080.01910.48
5.2.20.0100.01510.47
5.2.10.0070.01810.43
5.2.00.0080.01910.36
5.1.60.0070.01710.00
5.1.50.0080.02010.00
5.1.40.0100.0129.99
5.1.30.0100.01410.17
5.1.20.0110.01410.17
5.1.10.0090.01510.04
5.1.00.0050.01710.04
5.0.50.0040.0159.28
5.0.40.0090.0119.21
5.0.30.0050.0209.11
5.0.20.0110.0109.10
5.0.10.0080.0129.08
5.0.00.0070.0189.08
4.4.90.0060.0118.34
4.4.80.0030.0108.33
4.4.70.0050.0088.33
4.4.60.0070.0078.33
4.4.50.0020.0118.34
4.4.40.0040.0158.31
4.4.30.0030.0118.33
4.4.20.0060.0108.37
4.4.10.0050.0108.38
4.4.00.0040.0158.33
4.3.110.0030.0108.29
4.3.100.0050.0098.28
4.3.90.0060.0128.27
4.3.80.0040.0148.24
4.3.70.0020.0118.27
4.3.60.0040.0098.26
4.3.50.0010.0138.27
4.3.40.0040.0178.22
4.3.30.0020.0137.61
4.3.20.0040.0097.59
4.3.10.0010.0137.57
4.3.00.0020.01313.59

preferences:
43.31 ms | 401 KiB | 5 Q