3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { #[MyAttr(msg: __PROPERTY__)] public string $i = __PROPERTY__ { #[MyAttr(msg: __PROPERTY__)] get { var_dump(__PROPERTY__); // dumps "i" return $this->i; } set ( #[MyAttr(msg: __PROPERTY__)] string $v ) { $this->i = $v; } } } $f = new Foo(); var_dump($f->i); // dumps "" because it does not work in default value $r = new ReflectionClass(Foo::class); $p = $r->getProperty('i'); var_dump($p->getAttributes()[0]->getArguments()); // dumps "" because it does not work in property attributes $get = $p->getHook(PropertyHookType::Get); var_dump($get->getAttributes()[0]->getArguments()); // dumps "" because it does not work in hook attributes $set = $p->getHook(PropertyHookType::Set); var_dump($set->getParameters()[0]->getAttributes()[0]->getArguments()); // dumps "i" because it only works in parameter attributes

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.40.0230.01017.98
8.4.20.0210.01019.32
8.0.300.0200.00617.44
7.2.340.0160.01016.74
7.0.00.0150.00816.36
5.2.170.0120.00314.66
4.3.00.0050.00114.66

preferences:
158.36 ms | 997 KiB | 7 Q