3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Animal { protected $what = "nothing"; protected $born; public function __construct() { $this->born = time(); } function sound() { echo get_class($this)." says {$this->what}"; } function getBorn() { return $this->born; } } class Cow extends Animal { protected $what = "moo"; protected $owner; public function __construct($owner) { $this->owner = $owner; //must explicitly call parent::__construct to avoid wrong result; } } $a = new Cow("Old McDonald"); $a->sound(); echo "Cow was born on ",date("M j, Y",$a->getBorn());

preferences:
37.68 ms | 402 KiB | 5 Q