Hello,
With php4 I did the following in class initialisation :
class base_class {
function modify_polymorp hic($otherclass ){
$this=new $otherclass();
}
function other_function( ){
echo "Base method";
}
}
class herited_class extends base_class {
function other_function( ){
echo "Herited method";
}
}
$base=new base_class();
$base->modify_polymor phic("herited_c lass");
$base->other_function ();
This will echo "Herited method" in PHP 4.
But in PHP 5 it does not wand to work at all.
PHP interpreter says :
Fatal error: Cannot re-assign $this in scriptname.php on line 10
With php4 I did the following in class initialisation :
class base_class {
function modify_polymorp hic($otherclass ){
$this=new $otherclass();
}
function other_function( ){
echo "Base method";
}
}
class herited_class extends base_class {
function other_function( ){
echo "Herited method";
}
}
$base=new base_class();
$base->modify_polymor phic("herited_c lass");
$base->other_function ();
This will echo "Herited method" in PHP 4.
But in PHP 5 it does not wand to work at all.
PHP interpreter says :
Fatal error: Cannot re-assign $this in scriptname.php on line 10
Comment