Re: Herencia de clases y métodos
| From: | Kike | Date: | Fri, 12 Apr 2002 13:53:08 +0000 |
| Subject: | Re: Herencia de clases y métodos | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-21377@lists.php.net to get a copy of this message | ||
Hola Pablo,
Thursday, April 11, 2002, 7:57:23 PM, you wrote:
PMB> Hola amigos... hace rato que no me daba una vuelta por la lista,
PMB> motivos sobran creo... :)
PMB> Una consulta... Tengo una definición de clase, llamada CLASS_site,
PMB> con un método llamado AutoConfig()
PMB> class CLASS_site{
PMB> ...
PMB> ...
PMB> function AutoConfig(){
PMB> ....
PMB> ....
PMB> return;
PMB> }
PMB> ...
PMB> ...
PMB> }
PMB> Esta clase define las propiedades básicas que necesito para el
PMB> objeto oSite... Pero, a los efectos de "afinar" un poco más
PMB> este ofecto, normalmente creo otra clase a partir de esta, a
PMB> saber:
PMB> class CLASS_NewSite extends CLASS_site{
PMB> ...
PMB> ...
PMB> function AutoConfig(){
PMB> ...
PMB> ...
PMB> return;
PMB> }
PMB> ...
PMB> ...
PMB> }
PMB> Hasta acá nada raro... el problema surge es que dentro de
PMB> la nueva clase CLASS_NewSite necesito definir el mismo
PMB> método AutoConfig(). Lo que necesito saber es si esta nuevo
PMB> método reemplaza al anterior. Y si es así, cómo hago para
PMB> llamar al viejo AutoConfig.
PMB> Saludos
PMB> Pablo Beca
PMB> Santa Fe - Argentina
PMB> +------------------------------------------------+
PMB> | Vos también podés hacer algo desde "tu lugar"] |
PMB> | + SUMATE por Argentina, ahora que podemos |
PMB> + -----------------------------------------------+
PMB> | http://porargentina.enlapc.com |
PMB> +------------------------------------------------+
PMB> ---------------------------------------------------------------------
PMB> Archivo On-line: http://www.phpes.com/
PMB> via news: news://news.phpes.com/
PMB> Manual PHP en español: http://www.php.net/manual/es/
PMB> Para dar de baja la suscripción, mande un mensaje a:
PMB> lista-unsubscribe@phpes.com
Esto aparece en el manual, es un comentario de un usuario:
I just went through all sorts of playing around with the PHP object inheritance, and the following
is the best way to call an overloaded parent function as far as I can tell:
class a {
function init() {
echo "A init
";
}
}
class b extends a {
function init() {
a::init();
echo "B init
";
}
}
$x = new b;
$x->init();
This will output:
A init
B init
by calling the init() function of a within the init() function of b through the use of a::init() and
it seems to work just fine.
--
Saludos,
Kike mailto:kike@bytenet.es