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.3.140.0060.00919.07
8.3.130.0120.00317.10
8.3.120.0090.00021.10
8.3.110.0070.01320.94
8.3.100.0080.00024.06
8.3.90.0040.00426.77
8.3.80.0040.00716.88
8.3.70.0050.01016.86
8.3.60.0040.01118.56
8.3.50.0140.00718.50
8.3.40.0100.01019.05
8.3.30.0000.01819.02
8.3.20.0000.00824.18
8.3.10.0080.00024.66
8.3.00.0030.00526.16
8.2.250.0060.00317.04
8.2.240.0070.01117.48
8.2.230.0030.00622.58
8.2.220.0070.00337.54
8.2.210.0090.00926.77
8.2.200.0040.00416.63
8.2.190.0080.01116.63
8.2.180.0040.01125.92
8.2.170.0070.00719.02
8.2.160.0070.00722.96
8.2.150.0030.00625.66
8.2.140.0050.00324.66
8.2.130.0080.00026.16
8.2.120.0080.00019.88
8.2.110.0030.00622.44
8.2.100.0080.00418.16
8.2.90.0050.00318.00
8.2.80.0060.00319.07
8.2.70.0090.00017.88
8.2.60.0000.00818.05
8.2.50.0090.00017.98
8.2.40.0090.00017.72
8.2.30.0000.00817.98
8.2.20.0030.00519.50
8.2.10.0040.00417.96
8.2.00.0000.00819.47
8.1.300.0090.01218.73
8.1.290.0060.00330.84
8.1.280.0060.01225.92
8.1.270.0060.00323.90
8.1.260.0060.00326.35
8.1.250.0040.00428.09
8.1.240.0040.00420.32
8.1.230.0040.00717.96
8.1.220.0000.00817.89
8.1.210.0060.00318.77
8.1.200.0060.00317.63
8.1.190.0060.00317.48
8.1.180.0000.00818.10
8.1.170.0000.00817.80
8.1.160.0000.00719.03
8.1.150.0060.00318.92
8.1.140.0030.00517.63
8.1.130.0070.00019.10
8.1.120.0070.00017.63
8.1.110.0040.00417.63
8.1.100.0070.00017.67
8.1.90.0040.00417.63
8.1.80.0060.00317.70
8.1.70.0070.00017.61
8.1.60.0030.00617.69
8.1.50.0040.00417.64
8.1.40.0000.00817.64
8.1.30.0040.00417.85
8.1.20.0040.00417.85
8.1.10.0030.00617.80
8.1.00.0040.00417.64
8.0.300.0040.00419.30
8.0.290.0050.00317.00
8.0.280.0070.00018.62
8.0.270.0000.00716.95
8.0.260.0070.00018.79
8.0.250.0000.00817.23
8.0.240.0000.00817.23
8.0.230.0070.00017.16
8.0.220.0000.00817.09
8.0.210.0030.00317.13
8.0.200.0000.01217.08
8.0.190.0060.00317.07
8.0.180.0030.00517.18
8.0.170.0080.00017.14
8.0.160.0000.01117.11
8.0.150.0000.00716.95
8.0.140.0030.00617.01
8.0.130.0000.00613.52
8.0.120.0080.00413.48
8.0.110.0090.00413.42
8.0.100.0090.00413.50
8.0.90.0100.00313.60
8.0.80.0080.00413.51
8.0.70.0120.00013.54
8.0.60.0000.01213.48
8.0.50.0060.00613.45
8.0.30.0090.00313.41
8.0.20.0060.00613.62
8.0.10.0110.00013.55
8.0.00.0000.00713.68
7.4.330.0000.00515.55
7.4.320.0000.00616.69
7.4.300.0060.00016.89
7.4.290.0080.00016.75
7.4.280.0060.00316.70
7.4.270.0000.00816.87
7.4.260.0000.00513.55
7.4.250.0080.00013.48
7.4.240.0080.00413.56
7.4.230.0000.00813.60
7.4.220.0000.00713.46
7.4.210.0040.00513.48
7.4.200.0080.00313.40
7.4.190.0050.00513.57
7.4.180.0050.00613.63
7.4.160.0070.00213.51
7.4.150.0110.00013.48
7.4.140.0120.00013.35
7.4.130.0100.00313.46
7.4.120.0040.00513.29
7.4.110.0120.00013.46
7.4.100.0100.00013.37
7.4.90.0040.00813.39
7.4.80.0040.00413.40
7.4.70.0030.00613.41
7.4.60.0080.00013.38
7.4.50.0050.00513.32
7.4.40.0060.00313.36
7.4.30.0100.00013.38
7.4.20.0000.01113.39
7.4.10.0090.00013.40
7.4.00.0110.00013.40
7.3.330.0000.00716.12
7.3.320.0070.00513.21
7.3.310.0090.00312.92
7.3.300.0110.00013.03
7.3.290.0080.00413.01
7.3.280.0070.00412.96
7.3.270.0100.00313.03
7.3.260.0070.00212.98
7.3.250.0090.00313.19
7.3.240.0090.00412.95
7.3.230.0080.00413.11
7.3.220.0060.00613.20
7.3.210.0110.00312.85
7.3.200.0110.00213.00
7.3.190.0090.00412.89
7.3.180.0070.00712.92
7.3.170.0090.00513.10
7.3.160.0100.00412.78
7.3.150.0130.00013.04
7.3.140.0090.00513.08
7.3.130.0110.00212.89
7.3.120.0050.00812.99
7.3.110.0150.00213.10
7.3.100.0100.00312.82
7.3.90.0130.00013.16
7.3.80.0140.00013.22
7.3.70.0070.00713.14
7.3.60.0060.00313.27
7.3.50.0080.00313.34
7.3.40.0110.00012.94
7.3.30.0070.00512.95
7.3.20.0110.00014.73
7.3.10.0060.00414.46
7.3.00.0080.00314.61

preferences:
25.32 ms | 403 KiB | 5 Q