Hello!
Foo_Parent: this is foo
Foo_Abstact: this is foo
Foo_Child: this is foo
Goodbye.
<p>Hello!</p> | |
<hr> | |
<?php | |
ini_set('display_errors', 1); | |
ini_set('log_errors', 1); | |
ini_set('error_log', dirname(__FILE__) . '/error_log.txt'); | |
error_reporting(E_ALL); | |
include_once('class.child.php'); | |
new Foo_Child(); | |
?> | |
<hr> | |
<p>Goodbye.</p> |
<?php | |
include_once('class.abstract.php'); | |
class Foo_Child extends Foo_Abstact | |
{ | |
public function __construct() { | |
$foo = 'this is foo'; | |
parent::__construct($foo); | |
echo sprintf('<p>%s: %s</p>', __CLASS__, $foo); | |
} | |
} |
<?php | |
include_once('class.parent.php'); | |
abstract class Foo_Abstact extends Foo_Parent | |
{ | |
public function __construct($foo) { | |
parent::__construct($foo); | |
echo sprintf('<p>%s: %s</p>', __CLASS__, $foo); | |
} | |
} |
<?php | |
class Foo_Parent | |
{ | |
public function __construct($foo = 'nope') { | |
echo sprintf('<p>%s: %s</p>', __CLASS__, $foo); | |
} | |
} |
Hello!
Foo_Parent: this is foo
Foo_Abstact: this is foo
Foo_Child: this is foo
Goodbye.
Discussion here.