Re: extending a class

From: Date: Thu, 10 Apr 2003 18:10:44 +0000
Subject: Re: extending a class
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-143375@lists.php.net to get a copy of this message
apparently NOT! This might explain some of the wierd organization and cfg requirements in PHPLIB and other libraries. doing the base class name as a DEFINE: --------------------------------------- <?php class base{
    var $var=0;
} define ('base_class' , 'base'); class new_class extends base_class{
    var $new_var = 1;
} ?> giveS this error: - - - - - - - - - Fatal error: Class new_class: Cannot inherit from undefined class base_class in test_variable_base_class.php on line 6 doing the base class name as a VARIABLE: --------------------------------------- class base{
    var $var=0;
} $base_class = 'base'; class new_class extends $base_class{
    var $new_var = 1;
} ?> giveS this error: - - - - - - - - - Parse error: parse error, unexpected T_VARIABLE, expecting '{' in /home/virtual/site18/fst/var/www/html/dvlp/dennis/test_variable_base_class.php on line 6 Dennis Gearon wrote:
Is it possible to extend a class using a variable for the base class? I.E. $base_class = 'base'; class new_class extends $base_class{ stuff }


« previous php.general (#143375) next »