3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyParentClass { public function getProperty($propertyName) { return $this->{$propertyName}; } public function setProperty($propertyName, $value) { $this->{$propertyName} = $value; return $this; } } class MyChildClass extends MyParentClass { protected $foo; private $bar; } $child = new Child(); $child ->setProperty('foo', 'lulu') ->setProperty('bar', true); var_dump( $child->getProperty('foo'), $child->getProperty('bar') );

preferences:
56.34 ms | 402 KiB | 5 Q