3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class TimePeriod { private $Seconds; // Properties accessors are implemented just like you would define an actual property public $Hours { get() { return $this->Seconds / 3600; } // In the set accessor, the variable $x holds the incoming value to be "set" set($x) { $this->Seconds = $x * 3600; } } } // Accessing the property is the same as accessing a class member $time = new TimePeriod(); $time->Hours = 12; // Stored as 43200 echo $time->Hours; // Outputs 12
Output for 5.3.0 - 5.4.21
Parse error: syntax error, unexpected '{', expecting ',' or ';' in /in/e0MW8 on line 6
Process exited with code 255.