3v4l.org

run code in 300+ PHP versions simultaneously
<?php class foo { private $bar; function __construct () { $this->bar = 1; } function add() { $this->bar+=1; } } $one = $two = $three = new foo(); $two->add(); $three->add()->add(); var_dump($one); var_dump($two);

preferences:
44.63 ms | 402 KiB | 5 Q