- time: documentation ( source)
<?php
class Animal {
protected $what = "nothing";
protected $born;
function sound() {
echo get_class($this)." says {$this->what}";
}
public function __construct() {
$this->born = time();
}
}
class Cow extends Animal {
protected $what = "moo";
protected $owner;
public function __construct($owner) {
$this->owner = $owner;
// parent::__construct(); (?)
}
}
$a = new Cow("Old McDonald");
$a->sound();