3v4l.org

run code in 300+ PHP versions simultaneously
<?php class World { static $id = 0; protected $uid; protected $worldName; const $type = 'world'; public function __construct( $worldName ) { $this->setUID(); $this->wrldName = $worldName; } private function setUID() { $this->uid = self::$id++; } public function whoIsPerson( Person $person ) { $personUID = $person->getUID(); if( $personUID === 0 && $this->name === 'Rapture' ) return 'Jack'; elseif( $personUID === 0 && $this->name === 'Columbia' ) return 'Elizabeth'; else return 'Unknown Person'; } } class Person { static $id = 0; protected $uid; private function setUID() { $this->uid = self::$id++; } public function getUID() { return $this->uid; } } $person1 = new Person(); $world1 = new World('Rapture'); echo $world1->whoIsPerson( $person1 ); $world2 = new World('Columbia'); echo $world2->whoIsPerson( $person1 );
Output for 5.4.0 - 5.4.17, 5.5.0 - 5.5.1
Parse error: syntax error, unexpected '$type' (T_VARIABLE), expecting identifier (T_STRING) in /in/JpHBK on line 6
Process exited with code 255.
Output for 5.3.0 - 5.3.27
Parse error: syntax error, unexpected T_VARIABLE, expecting T_STRING in /in/JpHBK on line 6
Process exited with code 255.

preferences:
178.62 ms | 1395 KiB | 55 Q