Re: Re: static class member resolution

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



My example is only a shallow demonstration.  My expectations are correct as per the PHP specifications.

Regards
Loknath Bharti

> On May 16, 2015, at 21:57, Aziz Saleh <azizsaleh@xxxxxxxxx> wrote:
> 
> 
> 
> On Sat, May 16, 2015 at 10:55 AM, Christoph Becker <cmbecker69@xxxxxx <mailto:cmbecker69@xxxxxx>> wrote:
> Loknath Bharti wrote:
> 
> > I have the following in a class :
> >
> > $this->modelHandler = Handler;
> > $this->modelHandler::staticMethod();
> >
> > I am receiving a parse error problem in the second line.
> >
> > Handler is a class definition, and staticMethod is a static method. Handler is assigned to class variable modelHandler, but the above will return a parse Error. At the same time if I assign $this->modelHandler to a variable and call the staticMethod on that it works without a problem. I would like to make the above work, because its superfluous to have to assign a class Variable to a local variable to access it.
> >
> > $this->modelHandler = Handler;
> > $handler = $this->modelHandler;
> > $handler::staticMethod();
> >
> > The above works. Any insight into resolution by using something like {$this->modelHandler}::Handler would be appreciated.
> 
> You'll probably have to wait for PHP 7.0.0: <http://3v4l.org/mkPYY <http://3v4l.org/mkPYY>>. :)
> 
> --
> Christoph M. Becker
> 
> 
> --
> PHP General Mailing List (http://www.php.net/ <http://www.php.net/>)
> To unsubscribe, visit: http://www.php.net/unsub.php <http://www.php.net/unsub.php>
> 
> 
> If it is a static method, why not just do:
> 
> Handler::staticMethod();
> 
> No need to have any variables, you can straight out use the definition.


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux