RE: [PHP-ES] Herencia de clases y métodos
| From: | Pablo M. Beca | Date: | Fri, 12 Apr 2002 14:07:41 +0000 |
| Subject: | RE: [PHP-ES] Herencia de clases y métodos | ||
| References: | 1 | Groups: | php.general.es |
| Request: | Send a blank email to general-es+get-21379@lists.php.net to get a copy of this message | ||
Muchas gracias Kike, ya estoy probando esto...
+----------------------------+-------------------------------+
| Pablo M. Beca | ICQ # 77961561 |
| Analista Programador | e-mail: pablobeca@enlapc.com |
| | Linux User Number: 266591 |
| | www.linuxcounter.org |
+----------------------------+-------------------------------+
| +-----+--+ | |
| | | | INFOSOFT | Corrientes 2855 - Dpto. 3 |
| | | | Studio'S | 3000 - Santa Fe (SF) Rep.Arg. |
| +-----+--+ | Tel/Fax.: +54 (0342) 459-2482 |
| +-----+--+ soluciones .com | |
+----------------------------+-------------------------------+
| www.infosoftstudios.com.ar | mailto:infosoft@enlapc.com
|
+----------------------------+-------------------------------+
+------------------------------------------------+
| Vos también podés hacer algo desde "tu lugar"] |
| + SUMATE por Argentina, ahora que podemos |
+ -----------------------------------------------+
| http://porargentina.enlapc.com |
+------------------------------------------------+
-----Mensaje original-----
De: Kike [mailto:kike@bytenet.es]
Enviado el: Viernes, 12 de Abril de 2002 10:53
Para: Pablo M. Beca
CC: Lista PHP
Asunto: Re: [PHP-ES] Herencia de clases y métodos
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
---------------------------------------------------------------------
Archivo On-line: http://www.phpes.com/
via news: news://news.phpes.com/
Manual PHP en español: http://www.php.net/manual/es/
Para dar de baja la suscripción, mande un mensaje a:
lista-unsubscribe@phpes.com