Anonymous Class in PHP 7

As of PHP 7, we can define an anonymous class. It is highly useful when in a need for one object only. The new anonymous class can extend another class and implements as many interfaces as we want. When defining an anonymous class within the scope of another class we won’t get any access to any of the private or protected properties of the outer class.
Back to Top