3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class calc { private $state; public function __construct() { $this->state = 0; } public function add($number) { $this->state += $number; return $this; } public function mult($number) { $this->state = $this->state * $number; return $this; } public function echo() { echo $this->state; return $this; } } (new calc)->add(3)->add(7)->mult(3)->echo();
Output for 7.0.0 - 7.2.0
30
Output for 5.4.10 - 5.6.21
Parse error: syntax error, unexpected 'echo' (T_ECHO), expecting identifier (T_STRING) in /in/5DnJt on line 23
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected T_ECHO, expecting T_STRING in /in/5DnJt on line 23
Process exited with code 255.