If you're used to other object oriented programming languages, you're probably familiar with the constructor. You may also be familiar with the constructor being named as the class name. So it's just a method that shares the same name as the class name. In PHP, it's actually simplified in my opinion.
You name the constructor method, constructor with two underscores before it. Great, but what is the point of the constructor. It's there to initialize properties inside the object upon instantiation. PHP calls the constructor method automatically when the object is instantiated. Let's look at some code to see the constructor in detail.
Read the full article on my website
https://www.dinocajic.com/php-constru...
Code for this tutorial
https://github.com/dinocajic/php-7-yo...
Full Code
https://github.com/dinocajic/php-7-yo...
PHP Playlist
• PHP Tutorial
--
Dino Cajic
Author and Head of IT
Homepage: https://www.dinocajic.com
GitHub: https://github.com/dinocajic
Medium: / dinocajic
Instagram: / think.dino
LinkedIn: / dinocajic
Twitter: / dino_cajic
My Books
An Illustrative Introduction to Algorithms
https://www.amazon.com/dp/1686863268
Laravel Excel: Using Laravel to Import Data
https://amzn.to/4925ylw
Code Along With Me - PHP: From Basic to Advanced PHP Techniques
https://amzn.to/3M6tlGN
On this page of the site you can watch the video online Constructors - PHP - P49 with a duration of hours minute second in good quality, which was uploaded by the user Dino Cajic 06 June 2020, share the link with friends and acquaintances, this video has already been watched 271 times on youtube and it was liked by 11 viewers. Enjoy your viewing!