3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A {} $a = new A; $a->foo = "dynamic property"; $ro = new ReflectionObject($a); $prop = $ro->getProperty('foo'); try { var_dump($prop->getValue($a)); var_dump($prop->getValue(new A)); } catch (ReflectionException $ex) { echo "Caught!\n"; try { var_dump($prop->getValue(new A)); } catch (ReflectionException $ex) { var_dump($ex->getMessage()); } }
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Creation of dynamic property A::$foo is deprecated in /in/PHAvK on line 5 string(16) "dynamic property" Warning: Undefined property: A::$foo in /in/PHAvK on line 10 NULL
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
string(16) "dynamic property" Warning: Undefined property: A::$foo in /in/PHAvK on line 10 NULL
Output for 7.0.7 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
string(16) "dynamic property" Notice: Undefined property: A::$foo in /in/PHAvK on line 10 NULL
Output for 5.3.4 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.6, 7.3.32 - 7.3.33
string(16) "dynamic property" NULL
Output for 5.3.0 - 5.3.1, 5.3.3
NULL NULL
Output for 5.3.2
Notice: Corrupt member variable name in /in/PHAvK on line 9 Fatal error: Cannot access empty property in /in/PHAvK on line 9
Process exited with code 255.
Output for 5.2.7 - 5.2.17
Fatal error: Cannot access property started with '\0' in /in/PHAvK on line 9
Process exited with code 255.
Output for 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.6
Fatal error: Uncaught exception 'ReflectionException' with message 'Property foo does not exist' in /in/PHAvK:7 Stack trace: #0 /in/PHAvK(7): ReflectionClass->getProperty('foo') #1 {main} thrown in /in/PHAvK on line 7
Process exited with code 255.
Output for 5.0.3 - 5.0.4
Fatal error: Uncaught exception 'ReflectionException' with message 'Property foo does not exist' in /in/PHAvK:7 Stack trace: #0 /in/PHAvK(7): ReflectionObject->getProperty('foo') #1 {main} thrown in /in/PHAvK on line 7
Process exited with code 255.
Output for 5.0.1 - 5.0.2
Fatal error: Uncaught exception 'ReflectionException' with message 'Property foo does not exist' in /in/PHAvK:7 Stack trace: #0 {main} thrown in /in/PHAvK on line 7
Process exited with code 255.
Output for 5.0.0
Fatal error: Call to a member function getValue() on a non-object in /in/PHAvK on line 9
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected '{' in /in/PHAvK on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected '{' in /in/PHAvK on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/PHAvK on line 8
Process exited with code 255.

preferences:
331.6 ms | 401 KiB | 459 Q