3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * Allows value objects to expose their properties while maintaining immutability. * * Define your properties in the docblock for your class with {@code @property}. */ class Value { private $a; public function __construct($a) { $this->a = $a; } public function __get($aProperty) { if (property_exists($this, $aProperty)) { return $this->{$aProperty}; } $this->triggerError("Undefined property: %s::$%s", $aProperty); } public function __set($aProperty, $aValue) { if (property_exists($this, $aProperty)) { $this->triggerError("Cannot access private property %s::$%s", $aProperty); } $this->triggerError("Undefined property: %s::$%s", $aProperty); } private function triggerError($message, $aProperty) { $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); throw new ErrorException(sprintf($message, __CLASS__, $aProperty), 0, E_USER_NOTICE, $backtrace[2]['file'], $backtrace[2]['line']); } } $v = new Value(1); var_dump($v->a); var_dump($v->b); $v->a = 3; $v->b = 4;
Output for 8.3.0 - 8.3.27, 8.4.1 - 8.4.14, 8.4.16, 8.5.0 - 8.5.1
int(1) Warning: Undefined array key 2 in /in/TIQNE on line 32 Warning: Trying to access array offset on null in /in/TIQNE on line 32 Warning: Undefined array key 2 in /in/TIQNE on line 32 Warning: Trying to access array offset on null in /in/TIQNE on line 32 Fatal error: Uncaught ErrorException: Undefined property: Value::$b in /in/TIQNE:32 Stack trace: #0 /in/TIQNE(20): Value->triggerError('Undefined prope...', 'b') #1 /in/TIQNE(39): Value->__get('b') #2 {main} thrown in /in/TIQNE on line 32
Process exited with code 255.
Output for 8.4.15
/bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.4.15) /bin/php-8.4.15: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.4.15)
Process exited with code 1.
Output for 8.3.28
/bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libm.so.6: version `GLIBC_2.35' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.34' not found (required by /bin/php-8.3.28) /bin/php-8.3.28: /usr/lib/libc.so.6: version `GLIBC_2.38' not found (required by /bin/php-8.3.28)
Process exited with code 1.
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29
int(1) Warning: Undefined array key 2 in /in/TIQNE on line 32 Warning: Trying to access array offset on value of type null in /in/TIQNE on line 32 Warning: Undefined array key 2 in /in/TIQNE on line 32 Warning: Trying to access array offset on value of type null in /in/TIQNE on line 32 Fatal error: Uncaught ErrorException: Undefined property: Value::$b in /in/TIQNE:32 Stack trace: #0 /in/TIQNE(20): Value->triggerError('Undefined prope...', 'b') #1 /in/TIQNE(39): Value->__get('b') #2 {main} thrown in /in/TIQNE on line 32
Process exited with code 255.
Output for 7.4.0 - 7.4.33
int(1) Notice: Undefined offset: 2 in /in/TIQNE on line 32 Notice: Trying to access array offset on value of type null in /in/TIQNE on line 32 Notice: Undefined offset: 2 in /in/TIQNE on line 32 Notice: Trying to access array offset on value of type null in /in/TIQNE on line 32 Fatal error: Uncaught ErrorException: Undefined property: Value::$b in :0 Stack trace: #0 /in/TIQNE(20): Value->triggerError('Undefined prope...', 'b') #1 /in/TIQNE(39): Value->__get('b') #2 {main} thrown in Unknown on line 0
Process exited with code 255.
Output for 7.3.32 - 7.3.33
int(1) Fatal error: Uncaught ErrorException: Undefined property: Value::$b in :0 Stack trace: #0 /in/TIQNE(20): Value->triggerError('Undefined prope...', 'b') #1 /in/TIQNE(39): Value->__get('b') #2 {main} thrown in Unknown on line 0
Process exited with code 255.
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
int(1) Notice: Undefined offset: 2 in /in/TIQNE on line 32 Notice: Undefined offset: 2 in /in/TIQNE on line 32 Fatal error: Uncaught ErrorException: Undefined property: Value::$b in :0 Stack trace: #0 /in/TIQNE(20): Value->triggerError('Undefined prope...', 'b') #1 /in/TIQNE(39): Value->__get('b') #2 {main} thrown in Unknown on line 0
Process exited with code 255.
Output for 5.3.26 - 5.3.29, 5.4.16 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40
int(1) Notice: Undefined offset: 2 in /in/TIQNE on line 32 Notice: Undefined offset: 2 in /in/TIQNE on line 32 Fatal error: Uncaught exception 'ErrorException' with message 'Undefined property: Value::$b' in :0 Stack trace: #0 /in/TIQNE(20): Value->triggerError('Undefined prope...', 'b') #1 /in/TIQNE(39): Value->__get('b') #2 {main} thrown in Unknown on line 0
Process exited with code 255.
Output for 5.3.6 - 5.3.25, 5.4.0 - 5.4.15
int(1) Notice: Undefined offset: 2 in /in/TIQNE on line 32 Notice: Undefined offset: 2 in /in/TIQNE on line 32 Fatal error: Uncaught exception 'ErrorException' with message 'Undefined property: Value::$b' in :0 Stack trace: #0 /in/TIQNE(20): Value->triggerError('Undefined prope...', 'b') #1 /in/TIQNE(39): Value->__get('b') #2 {main} thrown in on line 0
Process exited with code 255.
Output for 5.3.0 - 5.3.5
int(1) Notice: Use of undefined constant DEBUG_BACKTRACE_IGNORE_ARGS - assumed 'DEBUG_BACKTRACE_IGNORE_ARGS' in /in/TIQNE on line 31 Notice: Undefined offset: 2 in /in/TIQNE on line 32 Notice: Undefined offset: 2 in /in/TIQNE on line 32 Fatal error: Uncaught exception 'ErrorException' with message 'Undefined property: Value::$b' in :0 Stack trace: #0 /in/TIQNE(20): Value->triggerError('Undefined prope...', 'b') #1 /in/TIQNE(39): Value->__get('b') #2 {main} thrown in on line 0
Process exited with code 255.
Output for 5.2.5 - 5.2.17
int(1) Notice: Use of undefined constant DEBUG_BACKTRACE_IGNORE_ARGS - assumed 'DEBUG_BACKTRACE_IGNORE_ARGS' in /in/TIQNE on line 31 Notice: Undefined offset: 2 in /in/TIQNE on line 32 Notice: Undefined offset: 2 in /in/TIQNE on line 32 Fatal error: Uncaught exception 'ErrorException' with message 'Undefined property: Value::$b' in :0 Stack trace: #0 /in/TIQNE(20): Value->triggerError('b') #1 /in/TIQNE(39): Value->__get() #2 {main} thrown in on line 0
Process exited with code 255.
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.4
int(1) Notice: Use of undefined constant DEBUG_BACKTRACE_IGNORE_ARGS - assumed 'DEBUG_BACKTRACE_IGNORE_ARGS' in /in/TIQNE on line 31 Warning: Wrong parameter count for debug_backtrace() in /in/TIQNE on line 31 Fatal error: Uncaught exception 'ErrorException' with message 'Undefined property: Value::$b' in :0 Stack trace: #0 /in/TIQNE(20): Value->triggerError('b') #1 /in/TIQNE(39): Value->__get() #2 {main} thrown in on line 0
Process exited with code 255.
Output for 5.1.0 - 5.1.2
int(1) Notice: Use of undefined constant DEBUG_BACKTRACE_IGNORE_ARGS - assumed 'DEBUG_BACKTRACE_IGNORE_ARGS' in /in/TIQNE on line 31 Warning: Wrong parameter count for debug_backtrace() in /in/TIQNE on line 31 Fatal error: Uncaught exception 'ErrorException' with message 'Undefined property: Value::$b' in :0 Stack trace: #0 /in/TIQNE(20): Value->triggerError('b') #1 /in/TIQNE(39): Value::__get() #2 {main} thrown in on line 0
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Fatal error: Cannot access private property Value::$a in /in/TIQNE on line 38
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/TIQNE on line 10
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 T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/TIQNE on line 10
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/TIQNE on line 10
Process exited with code 255.

preferences:
212.29 ms | 431 KiB | 5 Q