PHP Classes

Thanks for an overview

Recommend this page to a friend!

      PHP Classes blog  >  PHP 7 Anonymous Class...  >  All threads  >  Thanks for an overview  >  (Un) Subscribe thread alerts  
Subject:Thanks for an overview
Summary:Useful dynamic features
Messages:2
Author:Vallo Reima
Date:2015-10-14 05:38:49
Update:2015-10-14 06:37:04
 

  1. Thanks for an overview   Reply   Report abuse  
Picture of Vallo Reima Vallo Reima - 2015-10-14 05:43:58
It is a good addition to anonymous functions from php 5.3.

There is an option from php 5.4 to not retain the named class object accessing its method on instantiation, e.g.

echo (new namedClass)->returnProperty('myProp');

  2. Re: Thanks for an overview   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2015-10-14 06:37:04 - In reply to message 1 from Vallo Reima
I think closures where certainly the stepping stone that helped get anonymous classes voted in.

I do use the syntax you show for instantiating a named class in the next article on nested anonymous classes since they are nested within a named class. The article is currently in queue so it should be published soon.

Of course, your example is still instantiating a named class, where an anonymous class is instantiated and defined at the same time.

Dave