3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyFilter extends php_user_filter { private $data = ''; public function filter($in, $out, &$consumed, $closing) { $return = PSFS_FEED_ME; // While input data is available, continue to read it. while ($bucket_in = stream_bucket_make_writeable($in)) { $this->data .= $bucket_in->data; $consumed += $bucket_in->datalen; // Process whole lines. while (preg_match('/(.*?)[\r\n]+(.*)/s', $this->data, $match) === 1) { list(, $data, $this->data) = $match; // Send this record output. $data = strrev($data) . PHP_EOL; $bucket_out = stream_bucket_new($this->stream, $data); $return = PSFS_PASS_ON; stream_bucket_append($out, $bucket_out); } } // Process the final line. if ($closing && $this->data !== '') { $data = strrev($this->data) . PHP_EOL; $bucket_out = stream_bucket_new($this->stream, $data); $return = PSFS_PASS_ON; stream_bucket_append($out, $bucket_out); } return $return; } } stream_filter_register('my-filter', MyFilter::class); $input = "Line one\nLine two\nLine three"; $stream = fopen('data://text/plain,' . $input, 'r'); stream_filter_append($stream, 'my-filter'); $output = ''; while (!feof($stream)) { $output .= fread($stream, 16); } fclose($stream); echo $output;

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.0130.00618.61
8.3.50.0140.00418.46
8.3.40.0140.00419.19
8.3.30.0080.00818.89
8.3.20.0040.00419.26
8.3.10.0030.00521.75
8.3.00.0040.00420.58
8.2.180.0100.01316.88
8.2.170.0120.00922.96
8.2.160.0100.00322.29
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0030.00618.09
8.2.120.0050.00326.35
8.2.110.0030.00719.31
8.2.100.0080.01018.22
8.2.90.0050.00317.73
8.2.80.0030.00619.73
8.2.70.0040.00417.93
8.2.60.0000.00818.28
8.2.50.0000.00818.10
8.2.40.0000.01019.64
8.2.30.0040.00419.48
8.2.20.0040.00418.31
8.2.10.0040.00418.29
8.2.00.0040.00418.01
8.1.280.0110.01125.92
8.1.270.0080.00023.99
8.1.260.0040.00426.35
8.1.250.0000.00728.09
8.1.240.0030.00721.31
8.1.230.0070.00422.18
8.1.220.0000.00817.80
8.1.210.0030.00618.77
8.1.200.0050.00517.60
8.1.190.0100.00317.38
8.1.180.0030.00718.10
8.1.170.0060.00318.63
8.1.160.0050.00218.94
8.1.150.0040.00419.00
8.1.140.0030.00522.21
8.1.130.0070.00022.04
8.1.120.0000.00717.61
8.1.110.0000.00717.52
8.1.100.0040.00417.68
8.1.90.0040.00417.50
8.1.80.0050.00317.65
8.1.70.0040.00417.47
8.1.60.0060.00317.65
8.1.50.0040.00417.69
8.1.40.0040.00417.63
8.1.30.0040.00417.79
8.1.20.0040.00417.66
8.1.10.0040.00417.77
8.1.00.0050.00317.57
8.0.300.0050.00318.77
8.0.290.0000.00816.88
8.0.280.0050.00218.59
8.0.270.0000.00717.29
8.0.260.0030.00318.47
8.0.250.0040.00417.16
8.0.240.0030.00317.13
8.0.230.0070.00017.13
8.0.220.0030.00317.18
8.0.210.0030.00317.09
8.0.200.0000.00717.11
8.0.190.0050.00317.20
8.0.180.0040.00417.18
8.0.170.0060.00316.98
8.0.160.0000.00717.11
8.0.150.0060.00316.94
8.0.140.0030.00317.09
8.0.130.0000.00613.64
8.0.120.0000.00717.16
8.0.110.0090.00017.18
8.0.100.0000.00716.99
8.0.90.0040.00417.01
8.0.80.0110.00617.15
8.0.70.0050.00217.13
8.0.60.0040.00417.26
8.0.50.0040.00417.22
8.0.30.0080.00817.10
8.0.20.0100.01717.40
8.0.10.0030.00517.14
8.0.00.0130.01017.29
7.4.330.0030.00315.55
7.4.320.0070.00016.87
7.4.300.0050.00316.93
7.4.290.0040.00416.77
7.4.280.0100.00016.84
7.4.270.0030.00416.90
7.4.260.0090.00016.84
7.4.250.0030.00516.85
7.4.240.0050.00316.83
7.4.230.0030.00316.71
7.4.220.0030.00516.79
7.4.210.0070.00816.80
7.4.200.0050.00216.93
7.4.160.0090.01116.78
7.4.140.0110.01017.86
7.4.130.0150.01317.24
7.4.120.0130.00916.92
7.4.110.0180.01017.29
7.4.100.0190.00917.27
7.4.90.0170.00817.27
7.4.80.0190.00518.63
7.4.70.0150.01417.24
7.4.60.0160.01017.31
7.4.50.0190.00717.35
7.4.40.0170.00817.31
7.4.30.0280.00817.86
7.4.20.0200.01217.86
7.4.10.0300.00417.86
7.4.00.0150.00516.46
7.3.330.0030.00513.41
7.3.320.0060.00013.57
7.3.310.0030.00616.60
7.3.300.0030.00316.62
7.3.290.0080.00016.50
7.3.280.0130.00316.63
7.3.260.0220.00617.86
7.3.250.0230.01317.86
7.3.240.0130.00916.92
7.3.230.0210.00717.36
7.3.220.0290.00717.86
7.3.210.0180.00717.31
7.3.200.0180.00717.30
7.3.190.0220.00717.24
7.3.180.0220.00917.19
7.3.170.0240.00717.18
7.3.160.0200.00717.32
7.3.150.0240.01217.86
7.3.140.0240.01417.86
7.3.130.0300.01117.86
7.3.120.0250.01117.86
7.3.110.0190.01517.86
7.3.100.0250.00717.86
7.3.90.0240.00617.86
7.3.80.0240.00617.86
7.3.70.0210.01117.86
7.3.60.0300.00617.86
7.3.50.0240.01417.86
7.3.40.0280.00717.86
7.3.30.0280.00617.86
7.3.20.0260.00917.86
7.3.10.0190.01017.05
7.3.00.0220.00417.12
7.2.340.0260.01517.86
7.2.330.0150.01017.33
7.2.320.0160.01017.24
7.2.310.0160.01017.36
7.2.300.0190.00917.31
7.2.290.0180.00917.36
7.2.280.0330.00617.86
7.2.270.0230.01017.86
7.2.260.0130.02017.86
7.2.250.0230.01017.86
7.2.240.0270.01017.86
7.2.230.0260.00817.86
7.2.220.0180.01417.86
7.2.210.0180.01217.86
7.2.200.0290.00817.86
7.2.190.0280.01117.86
7.2.180.0280.01417.86
7.2.170.0320.00917.86
7.2.160.0350.00417.86
7.2.150.0350.01317.86
7.2.140.0180.01417.86
7.2.130.0230.01017.14
7.2.120.0170.01217.27
7.2.110.0350.00916.22
7.2.100.0430.00916.02
7.2.90.0520.00616.17
7.2.80.0440.00516.20
7.2.70.0370.00916.36
7.2.60.0430.01016.27
7.2.50.0460.00616.33
7.2.40.0340.01116.35
7.2.30.0340.01216.31
7.2.20.0410.00816.19
7.2.10.0500.00816.25
7.2.00.0370.00816.29
7.1.330.0230.01117.86
7.1.320.0270.00517.86
7.1.310.0220.01217.86
7.1.300.0270.00817.86
7.1.290.0180.01817.86
7.1.280.0390.00317.86
7.1.270.0280.01017.86
7.1.260.0240.01017.86
7.1.250.0180.01116.73
7.1.240.0220.00717.86
7.1.230.0670.00415.29
7.1.220.0590.01115.26
7.1.210.0500.00515.27
7.1.200.0540.00615.21
7.1.190.0420.00515.21
7.1.180.0660.00815.32
7.1.170.0400.00815.40
7.1.160.0450.00515.35
7.1.150.0340.01015.31
7.1.140.0390.00915.43
7.1.130.0350.01115.39
7.1.120.0340.00515.38
7.1.110.0440.00815.45
7.1.100.0450.00915.29
7.1.90.0250.00815.40
7.1.80.0260.00515.31
7.1.70.0280.01015.40
7.1.60.0500.01127.30
7.1.50.0480.01127.45
7.1.40.0540.01027.36
7.1.30.0660.00827.35
7.1.20.0340.01027.43
7.1.10.0410.00415.35
7.1.00.0290.00815.37
7.0.330.0220.01217.86
7.0.320.0290.00017.86
7.0.310.0520.00515.84
7.0.300.0450.00915.87
7.0.290.0460.00915.66
7.0.280.0410.00915.18
7.0.270.0360.01115.73
7.0.260.0410.00915.76
7.0.250.0350.00815.86
7.0.240.0310.01015.94
7.0.230.0240.01215.96
7.0.220.0240.00915.83
7.0.210.0270.01415.94
7.0.200.0310.00215.72
7.0.190.0290.00615.79
7.0.180.0230.00815.80
7.0.170.0270.00415.78
7.0.160.0160.01315.88
7.0.150.0210.00615.88
7.0.140.0220.00615.89
7.0.130.1720.00715.92
7.0.120.0250.00915.89
7.0.110.0270.00915.74
7.0.100.0260.00715.92
7.0.90.0210.00915.87
7.0.80.0230.00615.92
7.0.70.0220.00915.78
7.0.60.0260.00715.80
7.0.50.0260.00315.75
7.0.40.0300.00415.89
7.0.30.0220.01015.68
7.0.20.0260.00615.91
7.0.10.0190.00915.77
7.0.00.0240.00915.88
5.6.400.0190.01417.86
5.6.390.0190.01317.86
5.6.380.0130.00715.56
5.6.370.0170.01016.10
5.6.360.0190.00816.12
5.6.350.0180.01016.21
5.6.340.0160.00916.31
5.6.330.0190.00516.22
5.6.320.0210.00516.31
5.6.310.0150.01016.20
5.6.300.0130.01116.29
5.6.290.0150.01016.22
5.6.280.0170.01016.22
5.6.270.0150.01216.20
5.6.260.0190.00716.27
5.6.250.0160.00816.18
5.6.240.0130.01316.14
5.6.230.0160.01216.26
5.6.220.0180.00816.25
5.6.210.0220.00416.23
5.6.200.0170.01016.10
5.6.190.0180.01016.29
5.6.180.0190.00916.17
5.6.170.0130.01116.11
5.6.160.0130.01116.24
5.6.150.0210.00616.18
5.6.140.0160.00816.33
5.6.130.0220.00516.22
5.6.120.0150.01216.21
5.6.110.0140.01016.24
5.6.100.0210.00716.28
5.6.90.0120.01416.15
5.6.80.0190.00616.18
5.6.70.0080.01716.07
5.6.60.0170.00816.18
5.6.50.0170.00716.07
5.6.40.0180.00716.23
5.6.30.0140.01016.10
5.6.20.0160.00616.11
5.6.10.0160.01016.25
5.6.00.0130.00916.27

preferences:
50.38 ms | 401 KiB | 5 Q