3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Character { public $UID; public $Name; /* Other Variables */ public function __construct($conection, $UID) { #$details = $conection->prepare("SELECT * FROM Character_Details WHERE UID = ?"); #$details->bindParam(1, $UID); #$details->execute(); #$myDetails = $details->fetch(); $this->aName = 'Stuff'; # $myDetails['Name']; echo $this->aName . ': '; /* More variables set */ } public function DescribeMe() { echo "Character Description for: {$this->aName}"; /* Scenario A */ echo "Character Description for: {$aName}"; /* Scenario B */ echo "Character Description for: {self::$aName}"; /* Scenario C */ } } $char = new Character('param', 'param'); $char->DescribeMe();
Output for 5.0.4 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
Stuff: Character Description for: Stuff Notice: Undefined variable: aName in /in/UuPcJ on line 22 Character Description for: Notice: Undefined variable: aName in /in/UuPcJ on line 23 Character Description for: {self::}
Output for 5.0.0 - 5.0.3
Stuff: Character Description for: Stuff Notice: Undefined variable: aName in /in/UuPcJ on line 22 Character Description for: Notice: Undefined variable: aName in /in/UuPcJ on line 23 Character Description for: {self::}
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/UuPcJ on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/UuPcJ on line 4
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/UuPcJ on line 4
Process exited with code 255.