3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare (strict_types=1); final class Immutable { private $views; public function __construct(int $views) { $this->views = $views; } public function increaseViews(int $views): self { $this->views += $views; return new self($this->views); } public function getViews(): int { return $this->views; } } $imm = new Immutable(1); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); $imm->increaseViews(3); v print $imm->getViews();
Output for 7.1.0 - 7.1.17, 7.2.0 - 7.2.6
Parse error: syntax error, unexpected 'print' (T_PRINT) in /in/Z926t on line 36
Process exited with code 255.

preferences:
180.03 ms | 1395 KiB | 32 Q