3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { function __construct() { $this->a = "hello"; $this->b = "hi"; $this->val = "howdy"; $val = "a"; echo $this->{$val}; // outputs "hello" echo "\n"; $val = "b"; echo $this->{$val}; // outputs "hi" echo "\n"; echo $this->val; //outputs "howdy" echo "\n"; echo $this->{"val"}; setConfigParam('aVariableName', array('one', 'two', 'three')); echo->$aVariableName; } public function setConfigParam( $sName, $sValue ) { if ( isset( $this->$sName ) ) { $this->$sName = $sValue; } else { $this->_aConfigParams[$sName] = $sValue; } } } $foo = new foo();
Output for 5.4.0 - 5.4.29
Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR) in /in/ZT92B on line 25
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/ZT92B on line 25
Process exited with code 255.

preferences:
189.25 ms | 1386 KiB | 66 Q