[prev in list] [next in list] [prev in thread] [next in thread] 

List:       php-general-es
Subject:    Re: [PHP-ES] $this en Class
From:       "Diego Firmenich" <diego.firmenich () gmail ! com>
Date:       2008-04-16 17:02:57
Message-ID: 872eb1720804161002w11fb5833s8cf9e7d7cb3e360a () mail ! gmail ! com
[Download RAW message or body]


Lo que creo importante de resaltar aquí, que a juzgar por el código no estás
apreciando es lo siguiente:
Cuando tu llamas a tu metodo asi: Clase::Metodo() lo que estás tratando de
ejecutar es un Metodo de Clase, a los que comumente se llama estáticos.

Luego en tu implementación utilizas $this, siendo que $this representa LA
INSTANCIA de la clase Start a la que se le ha pasado el mensaje Iniciar.

Entonces el problema es que tu quieres invocar un metodo de clase (a method
that doesn't need to be invoked by an object of that class) Y en la
implementación de tal metodo requieres una Instancia de la clase.

Saludos.
Diego Firmenich.


On Wed, Apr 16, 2008 at 12:11 PM, Gustavo Pardo <dataneu@gmail.com> wrote:

> El mié, 16-04-2008 a las 11:31 -0300, Caco Patane escribió:
> > >  Pero cuando llamo a la clase así:
> > >  Start::Iniciar();
> >
> > Si la llamas asi:
> >
> > $s = new Start;
> > $s->Iniciar();
> >
> > No te va a tirar el error.
> >
> > Saludos,
> > CP.
>
> y si SIEMPRE llamarás a Iniciar() luego de instanciar la clase, renombra
> esa function a __construct() y te alcanzará sólo con:
>
> $s = new Start;
>
> saludos.
> --
> Gustavo Pardo
> Dataneu Argentina
> Software & Web Hosting
> Mail: gustavo.pardo@dataneu.com
> Web: http://dataneu.com/
> Tel.(+54 299) 489 6880
> Centenario, NQN - Argentina
>
>
> --
> PHP Spanish Localization Talk Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic