Hello,
Is it possible to instantiate a child class within the constructor of its
parent?
eg
Class DBI extends DB {
function DBI() {
// explicit parent constructor call
$this->DB();
$class = get_class($this );
if ($class != '' && $class != 'dbi') { // only do this
for child classes
$obj = new $class; // BORK!!
<snip>
I thought the syntax would be
$obj = new DBI::$class;
but that throws the lovely Hebrew error:
parse error, unexpected T_PAAMAYIM_NEKU DOTAYIM
Any help with this syntax or is this a forbidden act?
Thanks,
jg
Is it possible to instantiate a child class within the constructor of its
parent?
eg
Class DBI extends DB {
function DBI() {
// explicit parent constructor call
$this->DB();
$class = get_class($this );
if ($class != '' && $class != 'dbi') { // only do this
for child classes
$obj = new $class; // BORK!!
<snip>
I thought the syntax would be
$obj = new DBI::$class;
but that throws the lovely Hebrew error:
parse error, unexpected T_PAAMAYIM_NEKU DOTAYIM
Any help with this syntax or is this a forbidden act?
Thanks,
jg
Comment