PHP Anonymous Classes - Full PHP 8 Tutorial

Your video will begin in 10
89 Views
Published
In this lesson, you will learn what anonymous classes are in PHP, how to create & use them. Anonymous classes like anonymous functions are nameless. You are able to create one-off objects using anonymous classes. You can either assign an anonymous class to a variable that will simply give you the object of that anonymous class, or just pass it as an argument since it's just an expression.

Note that at 4:54 I copied constructor promoted properties & pasted them into the anonymous class. Promoted properties should not be used inside an anonymous class when you are extending from a base class since those already exist on the base class.

SOME OF THE WAYS YOU CAN SUPPORT THE CHANNEL
Category
Program With Gio
Tags
advanced php course, learn php the right way, object oriented php
Be the first to comment