3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Str { /** PHPの組み込み関数の第一引数に使う値をプロパティとしてセット */ public function __construct( public string $str ){} /** * このクラスで外部に公開していない名前のメソッドが呼ばれた場合に動作するマジックメソッド * @see https://www.php.net/manual/ja/language.oop5.overloading.php#object.call */ public function __call($name, $arguments) { // 呼ばれたメソッド名の関数を第一引数を最初に与えたプロパティ、 // 第二引数以降を呼ばれた際の引数として実行 $result = $name($this->str, ...$arguments); // 関数の返り値が文字列ならば返り値を元に自身のインスタンスを生成して返却 // 関数の返り値が文字列でないならば返り値をそのまま返却 return is_string($result) ? new self($result) : $result; } } $s = new Str('hoge'); echo $s->substr(0, 2) ->strtoupper() ->str_pad(4, '0', STR_PAD_LEFT) ->str; // 00HO

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.140.0040.00419.08
8.3.130.0030.00518.47
8.3.120.0050.00518.93
8.3.110.0040.00420.94
8.3.100.0080.00816.91
8.3.90.0060.00326.77
8.3.80.0030.00716.50
8.3.70.0110.00416.58
8.3.60.0040.01416.48
8.3.50.0120.00318.24
8.3.40.0070.00718.82
8.3.30.0150.00019.33
8.3.20.0000.00824.18
8.3.10.0040.00424.66
8.3.00.0070.00026.16
8.2.250.0080.00016.40
8.2.240.0100.00017.21
8.2.230.0070.00722.58
8.2.220.0080.00024.06
8.2.210.0080.00026.77
8.2.200.0090.00016.88
8.2.190.0150.00718.05
8.2.180.0120.00325.92
8.2.170.0100.01022.96
8.2.160.0030.01022.96
8.2.150.0000.00725.66
8.2.140.0070.00024.66
8.2.130.0080.00026.16
8.2.120.0060.00319.77
8.2.110.0050.00522.13
8.2.100.0070.00417.72
8.2.90.0050.00317.75
8.2.80.0100.00018.73
8.2.70.0030.00517.63
8.2.60.0000.00817.38
8.2.50.0040.00417.98
8.2.40.0080.00018.16
8.2.30.0020.00517.98
8.2.20.0020.00520.34
8.2.10.0000.00718.18
8.2.00.0030.00619.25
8.1.300.0060.00320.30
8.1.290.0030.00630.84
8.1.280.0070.00725.92
8.1.270.0080.00023.99
8.1.260.0100.00326.35
8.1.250.0000.00728.09
8.1.240.0090.00023.82
8.1.230.0040.00820.85
8.1.220.0040.00417.79
8.1.210.0000.00818.77
8.1.200.0090.00017.35
8.1.190.0040.00417.00
8.1.180.0040.00418.10
8.1.170.0030.00717.62
8.1.160.0000.00818.77
8.1.150.0050.00318.54
8.1.140.0070.00017.37
8.1.130.0030.00318.78
8.1.120.0040.00417.41
8.1.110.0040.00417.31
8.1.100.0000.00717.43
8.1.90.0040.00417.44
8.1.80.0000.00917.39
8.1.70.0080.00017.43
8.1.60.0000.00817.53
8.1.50.0110.00317.39
8.1.40.0200.00017.41
8.1.30.0120.00517.66
8.1.20.0070.01017.50
8.1.10.0070.00717.48
8.1.00.0110.00017.43
8.0.300.0080.00018.77
8.0.290.0000.00816.75
8.0.280.0030.00318.33
8.0.270.0030.00316.80
8.0.260.0000.00618.37
8.0.250.0070.00016.97
8.0.240.0060.00016.95
8.0.230.0030.00516.94
8.0.220.0070.00016.86
8.0.210.0000.00716.85
8.0.200.0030.00316.86
8.0.190.0000.00816.83
8.0.180.0130.00416.79
8.0.170.0100.00816.72
8.0.160.0150.00316.70
8.0.150.0170.00316.79
8.0.140.0120.00816.67
8.0.130.0160.00316.70
8.0.120.0200.00016.89
8.0.110.0150.00416.84
8.0.100.0170.00316.89
8.0.90.0160.00416.79
8.0.80.0150.00416.73
8.0.70.0210.00016.66
8.0.60.0160.00516.80
8.0.50.0180.00416.85
8.0.30.0180.00416.88
8.0.20.0110.00816.90
8.0.10.0150.00016.88
7.4.330.0000.00515.55
7.4.320.0040.00416.42
7.4.300.0060.00016.34
7.4.290.0020.00816.43
7.4.280.0100.00616.25
7.4.270.0150.00416.27
7.4.260.0110.01116.43
7.4.250.0180.00316.36
7.4.240.0180.00016.34
7.4.230.0150.00816.43
7.4.220.0140.00416.49
7.4.210.0160.00316.23
7.4.200.0190.00016.37
7.4.190.0140.00616.39
7.4.180.0150.00316.51
7.4.160.0130.00716.38
7.4.150.0180.00316.45
7.4.140.0180.00416.17
7.4.130.0130.00716.13
7.4.120.0180.00016.21
7.4.110.0190.00016.26
7.4.100.0160.00416.34
7.4.90.0150.00416.21
7.4.80.0080.00316.12
7.4.70.0120.00016.08
7.4.60.0030.00616.20
7.4.50.0090.00416.05
7.4.40.0160.00016.20
7.4.30.0090.00516.28
7.4.20.0100.00416.20
7.4.10.0100.00516.13
7.4.00.0070.00716.19

preferences:
56.77 ms | 403 KiB | 5 Q