3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { public $id; } class Foo2 { public $id; public function __construct($id) { $this->id = $id; } } class Foo3 { protected $id; public function __construct($id) { $this->id = $id; } public function getId() { return $this->id; } } class Foo4 { private $id; public function __construct($id) { $this->id = $id; } public function __get($key) { echo $key; return $this->id; } } $data = new Foo; $data->id = 10; echo $data->id; $data2 = new Foo2(10); echo $data2->id; $data3 = new Foo3(10); echo $data3->getId(); $data4 = new Foo4(10); echo $data4->id;
Output for 5.3.29 - 7.2.0
101010id10
Output for 4.3.0
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/Te4YC on line 4
Process exited with code 255.