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.0120.00916.88
8.3.60.0120.00318.45
8.3.50.0140.00621.98
8.3.40.0150.00018.85
8.3.30.0120.00318.98
8.3.20.0040.00420.20
8.3.10.0080.00021.85
8.3.00.0090.00017.80
8.2.180.0150.00416.38
8.2.170.0080.00822.96
8.2.160.0030.01020.47
8.2.150.0070.00024.18
8.2.140.0040.00424.66
8.2.130.0040.00426.16
8.2.120.0060.00320.44
8.2.110.0160.00622.03
8.2.100.0070.00421.12
8.2.90.0050.00319.09
8.2.80.0000.00817.97
8.2.70.0000.00917.48
8.2.60.0030.00717.91
8.2.50.0030.00618.07
8.2.40.0030.00618.09
8.2.30.0040.00418.13
8.2.20.0040.00817.68
8.2.10.0040.00418.04
8.2.00.0030.00517.73
8.1.280.0100.01025.92
8.1.270.0090.00023.84
8.1.260.0060.00326.35
8.1.250.0060.00328.09
8.1.240.0030.00618.57
8.1.230.0070.00419.22
8.1.220.0050.00317.79
8.1.210.0030.00518.77
8.1.200.0060.00317.35
8.1.190.0050.00317.23
8.1.180.0060.00318.10
8.1.170.0000.00818.59
8.1.160.0080.00021.98
8.1.150.0030.00518.74
8.1.140.0040.00417.33
8.1.130.0030.00317.83
8.1.120.0000.00717.37
8.1.110.0050.00317.32
8.1.100.0040.00417.29
8.1.90.0070.00417.39
8.1.80.0000.00717.25
8.1.70.0000.00717.38
8.1.60.0040.00417.41
8.1.50.0080.00017.42
8.1.40.0080.00317.58
8.1.30.0080.00017.65
8.1.20.0040.00417.57
8.1.10.0080.00017.64
8.1.00.0000.00717.47
8.0.300.0030.00518.77
8.0.290.0000.00816.88
8.0.280.0000.00818.34
8.0.270.0030.00317.28
8.0.260.0070.00017.14
8.0.250.0070.00016.96
8.0.240.0040.00416.89
8.0.230.0030.00317.00
8.0.220.0050.00316.84
8.0.210.0030.00316.89
8.0.200.0060.00317.05
8.0.190.0040.00416.92
8.0.180.0000.00717.02
8.0.170.0060.00317.04
8.0.160.0000.00816.83
8.0.150.0070.00016.89
8.0.140.0000.00716.84
8.0.130.0030.00313.35
8.0.120.0030.00516.96
8.0.110.0050.00216.90
8.0.100.0000.00716.95
8.0.90.0070.00016.77
8.0.80.0070.01417.01
8.0.70.0000.00716.86
8.0.60.0040.00416.96
8.0.50.0080.00016.86
8.0.30.0100.01117.21
8.0.20.0160.00617.40
8.0.10.0030.00516.96
8.0.00.0140.00616.79
7.4.330.0030.00315.67
7.4.320.0000.00717.09
7.4.300.0030.00317.18
7.4.290.0040.00717.18
7.4.280.0040.00417.25
7.4.270.0050.00317.15
7.4.260.0030.00317.08
7.4.250.0030.00617.18
7.4.240.0040.00417.20
7.4.230.0000.00817.27
7.4.220.0090.01217.09
7.4.210.0030.01717.16
7.4.200.0070.00017.08
7.4.160.0050.01117.12
7.4.150.0160.00717.40
7.4.140.0120.00817.86
7.4.130.0070.01117.12
7.4.120.0130.00516.97
7.4.110.0070.01116.88
7.4.100.0110.00816.98
7.4.90.0110.00717.15
7.4.80.0220.01219.39
7.4.70.0160.00817.16
7.4.60.0170.01217.02
7.4.50.0140.00616.95
7.4.40.0160.00816.98
7.4.30.0220.00816.94
7.4.20.0320.01217.08
7.4.10.0250.01417.11
7.4.00.0100.01116.21
7.3.330.0050.00013.87
7.3.320.0060.00013.85
7.3.310.0080.00016.74
7.3.300.0000.00716.77
7.3.290.0140.00716.94
7.3.280.0120.00716.88
7.3.270.0160.00317.40
7.3.260.0110.01416.97
7.3.250.0100.01016.88
7.3.240.0130.00716.97
7.3.230.0140.00316.73
7.3.210.0140.00316.93
7.3.200.0090.01316.84
7.3.190.0130.01916.85
7.3.180.0180.01016.82
7.3.170.0150.01016.75
7.3.160.0120.01216.89
7.3.150.0190.01516.91
7.3.140.0260.01017.10
7.3.130.0280.00917.07
7.3.120.0120.01115.86
7.3.110.0210.00916.79
7.3.100.0190.00816.87
7.3.90.0320.00416.97
7.3.80.0180.00617.03
7.3.70.0140.00716.71
7.3.60.0150.00616.89
7.3.50.0210.00016.94
7.3.40.0190.00816.89
7.3.30.0260.00416.77
7.3.20.0070.01516.79
7.3.10.0100.01016.79
7.3.00.0070.01216.93
7.2.330.0000.01917.25
7.2.320.0060.01217.27
7.2.310.0150.01117.06
7.2.300.0140.01017.07
7.2.290.0220.00817.02
7.2.280.0250.00917.06
7.2.270.0300.00816.92
7.2.260.0210.01517.25
7.2.250.0130.01016.98
7.2.240.0190.00517.01
7.2.230.0100.02417.05
7.2.220.0290.00316.82
7.2.210.0070.01417.02
7.2.200.0000.02417.00
7.2.190.0170.00317.02
7.2.180.0110.01217.00
7.2.170.0350.00317.08
7.2.160.0250.01117.18
7.2.150.0120.01017.04
7.2.140.0200.00317.02
7.2.130.0100.01117.06
7.2.120.0120.00417.02
7.2.110.0080.01217.02
7.2.100.0120.00717.05
7.2.90.0120.00616.96
7.2.80.0100.01117.10
7.2.70.0120.00617.08
7.2.60.0130.00617.09
7.2.50.0060.01516.93
7.2.40.0100.01216.99
7.2.30.0150.00916.95
7.2.20.0290.00517.08
7.2.10.0110.00917.02
7.2.00.0040.01017.83
7.1.330.0890.00316.00
7.1.320.0150.01515.94
7.1.310.0130.01416.32
7.1.300.0180.01116.16
7.1.290.0170.01416.07
7.1.280.0200.00916.13
7.1.270.0280.00616.07
7.1.260.0210.01016.05
7.1.250.0160.00916.07
7.1.240.0410.00315.93
7.1.230.0280.00616.13
7.1.220.0950.01016.10
7.1.210.0300.00516.18
7.1.200.0220.00816.07
7.1.190.0210.01216.03
7.1.180.0210.00916.10
7.1.170.0170.01416.03
7.1.160.0230.01016.15
7.1.150.0130.01616.11
7.1.140.0220.00816.14
7.1.130.0320.00015.97
7.1.120.0320.00016.09
7.1.110.0210.01316.04
7.1.100.0180.00817.12
7.1.90.0270.00516.09
7.1.80.0250.00616.14
7.1.70.0100.00716.71
7.1.60.0150.01317.69
7.1.50.0120.01216.72
7.1.40.0140.01516.07
7.1.30.0220.00716.07
7.1.20.0240.00615.98
7.1.10.0260.01316.15
7.1.00.0130.04219.31
7.0.330.0240.00615.73
7.0.320.0180.01115.86
7.0.310.0200.00715.86
7.0.300.0140.01615.85
7.0.290.0220.00815.81
7.0.280.0220.00716.06
7.0.270.0670.01315.73
7.0.260.0120.01715.62
7.0.250.0150.01615.99
7.0.240.0200.00715.96
7.0.230.0260.00615.79
7.0.220.0190.01015.95
7.0.210.0150.01515.66
7.0.200.0120.01216.26
7.0.190.0220.00915.88
7.0.180.0230.00615.75
7.0.170.0240.00915.91
7.0.160.0240.00915.97
7.0.150.0190.01015.80
7.0.140.0140.03818.88
7.0.130.0140.01415.73
7.0.120.0290.00015.98
7.0.110.0190.01015.80
7.0.100.0160.01015.85
7.0.90.0160.01215.81
7.0.80.0240.00415.88
7.0.70.0180.01015.81
7.0.60.0220.04217.97
7.0.50.0150.02816.80
7.0.40.0200.03017.88
7.0.30.0270.04117.97
7.0.20.0140.03417.97
7.0.10.0180.04617.96
7.0.00.0060.04018.04
5.6.400.0250.01816.46
5.6.390.0200.01016.50
5.6.380.0160.01316.31
5.6.370.0180.01116.42
5.6.360.0190.01116.47
5.6.350.0200.01016.59
5.6.340.0150.01016.65
5.6.330.0250.01316.48
5.6.320.0210.00816.50
5.6.310.0180.01516.22
5.6.300.0190.00916.47
5.6.290.0130.01816.19
5.6.280.0150.03818.67
5.6.270.0210.01416.45
5.6.260.0170.01016.36
5.6.250.0180.00916.43
5.6.240.0190.01116.25
5.6.230.0190.01016.68
5.6.220.0280.00716.31
5.6.210.0130.03518.46
5.6.200.0140.03717.32
5.6.190.0150.04018.49
5.6.180.1870.02718.60
5.6.170.0280.02618.46
5.6.160.0110.05218.50
5.6.150.0140.04917.18
5.6.140.0150.02717.40
5.6.130.0140.03617.41
5.6.120.0110.03118.76
5.6.110.0120.05218.71
5.6.100.0150.05018.68
5.6.90.0110.02818.66
5.6.80.0100.04318.40
5.6.70.2190.02618.31
5.6.60.0150.00316.28
5.6.50.0130.01616.51
5.6.40.0130.01016.23
5.6.30.0160.00316.27
5.6.20.0200.02516.39
5.6.10.0090.01916.23
5.6.00.0100.01016.33
5.5.380.0210.00716.47
5.5.370.0250.01116.61
5.5.360.0220.01116.14
5.5.350.0100.03418.34
5.5.340.0160.04517.15
5.5.330.0160.03718.46
5.5.320.1610.02718.29
5.5.310.0250.04318.40
5.5.300.0130.04417.07
5.5.290.0120.04817.28
5.5.280.0180.04618.64
5.5.270.0110.05018.59
5.5.260.0170.03318.63
5.5.250.0130.02518.28
5.5.240.0200.02418.18
5.5.230.0210.00616.32
5.5.220.0170.01116.32
5.5.210.0140.01416.27
5.5.200.0160.01616.32
5.5.190.0250.01016.20
5.5.180.0130.02016.32
5.5.170.0170.02115.97
5.5.160.0140.01416.46
5.5.150.0200.01016.22
5.5.140.0180.01816.23
5.5.130.0220.01416.22
5.5.120.0250.01415.89
5.5.110.0190.01916.51
5.5.100.0210.00816.19
5.5.90.0240.01316.13
5.5.80.0280.00016.25
5.5.70.0200.01116.07
5.5.60.0230.00916.12
5.5.50.0230.00516.21
5.5.40.0200.00715.95
5.5.30.0130.01416.21
5.5.20.0170.00916.23
5.5.10.0220.00816.28
5.5.00.0240.00616.18
5.4.450.0280.02516.52
5.4.440.0260.02816.30
5.4.430.0310.02516.26
5.4.420.0330.02116.13
5.4.410.0090.02816.31
5.4.400.0180.02116.00
5.4.390.0350.02416.29
5.4.380.0490.03015.86
5.4.370.0440.03016.00
5.4.360.0340.03615.72
5.4.350.0690.04315.95
5.4.340.0460.03415.86
5.4.330.0130.01013.23
5.4.320.0050.02812.83
5.4.310.0120.02412.82
5.4.300.0100.02312.92
5.4.290.0130.01912.80
5.4.280.0150.01612.79
5.4.270.0040.02812.74
5.4.260.0110.02412.85
5.4.250.0120.02112.77
5.4.240.0100.02212.67
5.4.230.0080.02512.70
5.4.220.0080.02512.68
5.4.210.0100.02212.72
5.4.200.0120.02412.81
5.4.190.0130.01912.75
5.4.180.0090.02612.77
5.4.170.0100.02312.86
5.4.160.0090.02312.76
5.4.150.0070.02512.71
5.4.140.0110.02012.71
5.4.130.0120.02312.54
5.4.120.0110.02112.66
5.4.110.0110.02412.62
5.4.100.0150.01612.54
5.4.90.0070.02512.59
5.4.80.0130.02112.56
5.4.70.0110.02112.57
5.4.60.0100.02212.55
5.4.50.0130.02012.57
5.4.40.0130.01912.63
5.4.30.0140.02612.50
5.4.20.0110.02412.64
5.4.10.0090.02012.54
5.4.00.0090.02312.30
5.3.290.0100.02512.79
5.3.280.0110.02212.69
5.3.270.0070.02712.75
5.3.260.0120.02212.79
5.3.250.0110.02212.75
5.3.240.0070.02512.80
5.3.230.0110.02312.69
5.3.220.0110.02412.67
5.3.210.0130.02112.67
5.3.200.0080.02912.69
5.3.190.0130.02312.69
5.3.180.0130.02312.77
5.3.170.0110.02712.82
5.3.160.0070.02812.83
5.3.150.0060.02612.77
5.3.140.0100.02312.72
5.3.130.0120.02312.72
5.3.120.0110.02312.79
5.3.110.0110.02312.87
5.3.100.0120.02112.60
5.3.90.0110.02112.50
5.3.80.0120.02212.44
5.3.70.0130.02212.47
5.3.60.0100.02112.52
5.3.50.0070.02412.36
5.3.40.0100.02512.38
5.3.30.0100.02412.49
5.3.20.0110.02212.26
5.3.10.0130.01912.18
5.3.00.0090.02312.15
5.2.170.0110.01710.56
5.2.160.0090.01810.58
5.2.150.0110.01810.59
5.2.140.0100.02010.56
5.2.130.0090.01810.54
5.2.120.0110.01810.54
5.2.110.0100.01610.55
5.2.100.0060.02010.54
5.2.90.0060.02110.54
5.2.80.0100.01610.54
5.2.70.0090.02210.54
5.2.60.0080.02210.52
5.2.50.0050.02110.50
5.2.40.0090.01610.54
5.2.30.0070.02010.48
5.2.20.0080.01910.47
5.2.10.0100.01510.43
5.2.00.0090.01610.36
5.1.60.0060.01610.00
5.1.50.0050.01810.00
5.1.40.0080.0149.99
5.1.30.0120.01510.17
5.1.20.0100.01410.17
5.1.10.0080.01710.03
5.1.00.0090.01410.04
5.0.50.0080.0129.27
5.0.40.0090.0109.21
5.0.30.0060.0189.11
5.0.20.0060.0149.10
5.0.10.0090.0099.08
5.0.00.0060.0229.08
4.4.90.0050.0108.34
4.4.80.0050.0108.33
4.4.70.0050.0098.33
4.4.60.0040.0108.33
4.4.50.0040.0098.34
4.4.40.0040.0158.31
4.4.30.0060.0098.33
4.4.20.0040.0138.37
4.4.10.0020.0128.38
4.4.00.0010.0178.33
4.3.110.0050.0088.28
4.3.100.0050.0098.28
4.3.90.0050.0098.27
4.3.80.0040.0168.24
4.3.70.0030.0118.27
4.3.60.0060.0078.26
4.3.50.0040.0098.26
4.3.40.0030.0158.22
4.3.30.0030.0107.61
4.3.20.0020.0117.59
4.3.10.0030.0117.57
4.3.00.0100.00813.59

preferences:
48.08 ms | 401 KiB | 5 Q