3v4l.org

run code in 300+ PHP versions simultaneously
<?php class CanCastBool extends SimpleXMLElement { /** @var WeakMap 各 CanCastBool インスタンスのプロパティを保持する WeakMap */ public static WeakMap $properties; /** * XML を意識しないコンストラクタ * @param string $fuga * @return CanCastBool */ public static function makeInstance(string $fuga): CanCastBool { $instance = new self('<bool></bool>'); $instance->true = true; self::$properties ??= new WeakMap(); // WeakMap に自分をキーにしてプロパティを記録させる // WeakMap に退避させておくので XML とは別の扱いになる self::$properties[$instance] = [ 'fuga' => $fuga, ]; return $instance; } /** プロパティ的に読み取るメソッド。WeakMap から取ってくる */ public function getP(string $name) { return self::$properties[$this][$name]; } /** プロパティ的にセットするメソッド。WeakMap にセットする */ public function setP($name, $value) { self::$properties[$this][$name] = $value; } public function toTrue(): void { $this->true = true; } public function toFalse(): void { unset($this->true); } } $a = CanCastBool::makeInstance('fugafuga'); $b = CanCastBool::makeInstance('piyopiyo'); echo "---init----\n"; var_dump((bool)$a);// true var_dump($a->getP('fuga'));// 'fugafuga' $a->setP('fuga', 'foo'); $a->setP('hoge', 'bar'); echo "----------\n"; $a->toFalse(); var_dump((bool)$a);// false var_dump($a->getP('fuga'));// 'foo' var_dump($a->getP('hoge'));// 'bar' $a->setP('hoge', 'hogehoge'); echo "----------\n"; $a->toTrue(); var_dump((bool)$a);// true var_dump($a->getP('fuga'));// 'foo' var_dump($a->getP('hoge'));// 'hogehoge' var_dump($b->getP('fuga'));// 'piyopiyo'

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.4.20.0140.00619.80
8.4.10.0180.00218.74
8.3.150.0120.00617.54
8.3.140.0180.00917.91
8.3.130.0140.00616.90
8.3.120.0100.00318.92
8.3.110.0070.01218.81
8.3.100.0150.00420.44
8.3.90.0120.00221.66
8.3.80.0070.00916.72
8.3.70.0110.00716.89
8.3.60.0100.00817.68
8.3.50.0170.00517.75
8.3.40.0130.00818.35
8.3.30.0070.01218.40
8.3.20.0060.00720.76
8.3.10.0100.00221.14
8.3.00.0070.00321.91
8.2.260.0080.00416.61
8.2.250.0080.00516.93
8.2.240.0110.00717.04
8.2.230.0100.00319.50
8.2.220.0100.00326.98
8.2.210.0100.00821.70
8.2.200.0080.00416.52
8.2.190.0100.00916.63
8.2.180.0100.00621.22
8.2.170.0130.00418.39
8.2.160.0080.00820.29
8.2.150.0070.00621.52
8.2.140.0080.00721.12
8.2.130.0110.00321.79
8.2.120.0130.00018.74
8.2.110.0100.00419.96
8.2.100.0090.00617.80
8.2.90.0080.00517.73
8.2.80.0100.00518.37
8.2.70.0110.00317.69
8.2.60.0070.00617.76
8.2.50.0110.00217.72
8.2.40.0090.00317.70
8.2.30.0080.00417.78
8.2.20.0100.00318.58
8.2.10.0080.00517.70
8.2.00.0040.00918.48
8.1.310.0020.00717.85
8.1.300.0130.00617.39
8.1.290.0080.00523.53
8.1.280.0100.00821.05
8.1.270.0100.00320.66
8.1.260.0110.00221.87
8.1.250.0100.00322.66
8.1.240.0090.00518.78
8.1.230.0090.00517.68
8.1.220.0060.00617.58
8.1.210.0120.00118.12
8.1.200.0080.00417.42
8.1.190.0090.00517.30
8.1.180.0050.00917.57
8.1.170.0090.00417.68
8.1.160.0050.00618.20
8.1.150.0070.00618.13
8.1.140.0040.00717.47
8.1.130.0100.00118.17
8.1.120.0120.00017.46
8.1.110.0100.00217.59
8.1.100.0090.00217.66
8.1.90.0080.00517.43
8.1.80.0100.00317.39
8.1.70.0100.00117.43
8.1.60.0070.00717.54
8.1.50.0090.00417.54
8.1.40.0060.00717.59
8.1.30.0110.00217.62
8.1.20.0070.00517.68
8.1.10.0090.00417.74
8.1.00.0110.00217.45
8.0.300.0070.00617.89
8.0.290.0120.00116.81
8.0.280.0130.00017.59
8.0.270.0040.00816.99
8.0.260.0120.00117.75
8.0.250.0090.00416.92
8.0.240.0050.00716.89
8.0.230.0130.00016.95
8.0.220.0060.00616.85
8.0.210.0080.00616.88
8.0.200.0080.00616.95
8.0.190.0080.00416.97
8.0.180.0090.00316.86
8.0.170.0090.00317.00
8.0.160.0080.00517.02
8.0.150.0060.00516.84
8.0.140.0080.00416.81
8.0.130.0060.00515.13
8.0.120.0120.00215.07
8.0.110.0120.00214.86
8.0.100.0080.00615.02
8.0.90.0120.00315.07
8.0.80.0120.00215.10
8.0.70.0140.00015.03
8.0.60.0060.00814.99
8.0.50.0090.00515.09
8.0.30.0130.00115.06
8.0.20.0080.00515.13
8.0.10.0130.00015.14
8.0.00.0070.00515.19
7.4.330.0080.00316.02
7.4.320.0080.00316.46
7.4.300.0090.00316.74
7.4.290.0120.00016.54
7.4.280.0060.00716.61
7.4.270.0080.00416.67
7.4.260.0060.00414.90
7.4.250.0100.00214.87
7.4.240.0090.00514.86
7.4.230.0040.00915.01
7.4.220.0060.00514.96
7.4.210.0100.00214.94
7.4.200.0100.00314.98
7.4.190.0090.00415.00
7.4.180.0050.00715.04
7.4.160.0090.00314.94
7.4.150.0120.00114.82
7.4.140.0120.00214.93
7.4.130.0120.00214.87
7.4.120.0100.00214.76
7.4.110.0130.00014.95
7.4.100.0130.00314.81
7.4.90.0080.00514.73
7.4.80.0060.00614.84
7.4.70.0070.00615.02
7.4.60.0110.00014.81
7.4.50.0100.00214.85
7.4.40.0110.00214.80
7.4.30.0080.00414.85
7.4.20.0030.00914.82
7.4.10.0070.00514.81
7.4.00.0120.00114.83
7.3.330.0040.00715.83
7.3.320.0100.00214.60
7.3.310.0100.00314.28
7.3.300.0130.00014.54
7.3.290.0100.00414.29
7.3.280.0050.00714.37
7.3.270.0090.00514.43
7.3.260.0100.00214.28
7.3.250.0110.00314.58
7.3.240.0080.00514.43
7.3.230.0090.00414.45
7.3.220.0090.00414.48
7.3.210.0130.00114.46
7.3.200.0100.00514.33
7.3.190.0100.00414.22
7.3.180.0110.00414.42
7.3.170.0130.00214.37
7.3.160.0100.00414.20
7.3.150.0110.00314.36
7.3.140.0070.00814.43
7.3.130.0110.00214.26
7.3.120.0100.00414.30
7.3.110.0150.00214.27
7.3.100.0110.00314.30
7.3.90.0140.00014.62
7.3.80.0100.00314.43
7.3.70.0100.00314.46
7.3.60.0050.00614.61
7.3.50.0090.00314.59
7.3.40.0090.00414.34
7.3.30.0100.00214.39
7.3.20.0150.00016.20
7.3.10.0090.00316.09
7.3.00.0120.00116.10

preferences:
66.26 ms | 403 KiB | 5 Q