3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { $foo; } class Bar extends Foo { $bar; } $barClassReflection = new ReflectionClass(Bar::class); $properties = $barClassReflection->getProperties(); var_dump($properties); foreach ($properties as $property) { var_dump($property->getName()); var_dump($property->class); var_dump($property->getDeclaringClass()->getName()); var_dump($property->class === $property->getDeclaringClass()->getName()); }
Output for 7.1.25, 7.2.0 - 7.2.13, 7.3.0
Parse error: syntax error, unexpected '$foo' (T_VARIABLE), expecting function (T_FUNCTION) or const (T_CONST) in /in/Qg9jI on line 5
Process exited with code 255.
Output for 5.6.38, 7.0.33
Parse error: syntax error, unexpected '$foo' (T_VARIABLE), expecting function (T_FUNCTION) in /in/Qg9jI on line 5
Process exited with code 255.

preferences:
166.73 ms | 1395 KiB | 25 Q