3v4l.org

run code in 300+ PHP versions simultaneously
<?php (new class { private $state; public function __construct() { $this->state = 0; } public function add($number) { $this->state += $number; return $this; } public function mult($number) { $this->state =* $number; return $this; } public function echo() { echo $this->state; return $this; } })->add(3)->add(7)->mult(3)->echo();
Output for 7.0.0
Parse error: syntax error, unexpected '*' in /in/7rTem on line 19
Process exited with code 255.
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/7rTem on line 3
Process exited with code 255.

preferences:
156.13 ms | 1399 KiB | 24 Q