This is the complete 6 part PHP Object Oriented Programming course for beginners course from How To Code Well.

This course includes the following PHP tutorials:

PHP OOP Tutorial 1 Class Vs Objects (0:00)
PHP OOP Tutorial 2 Class Inheritance (15:37)
PHP OOP Tutorial 3 Visibility Scopes (27:59)
PHP OOP Tutorial 4 Property Overloading50:05)
PHP OOP Tutorial 5 Class Constants (01:06:06)
PHP OOP Tutorial 6 Static Keyword (01:09:19)

Learn how to code well with the below programming resources and discounts

Programming and web development courses
Docker in Motion (40% OFF – ytfisher)-
Hands-on Microservices In Python –
Master Python Clean Coding –
Docker For beginners –
AWS S3 Command Line –
PHP MYSQLi For Beginners –
PHP Control Structures –
PHP String Manipulation -
How To Code Well courses on SkillShare –
How To Code Well courses on Udmey –

Recommended resources for web developers – Our Affiliates, Referral Programs, and Sponsors
NordVPN –
WordPress Hosting with CloudWays –
VPS hosting with Hostinger –
Manning Publications books and video courses –

Join the coding community on Discord –

Twitter –
Instagram –
Facebook –
Newsletter –

Live coding
Join me on Twitch –
Tues, Wed, Thurs, Sunday

DISCLAIMER: This video and description contains affiliate links, which means that if you click on one of the product links, I’ll receive a small commission. This helps support the channel and allows me to continue to make web development videos like this. Thank you for the support!

#php #oop #learnToCode

Comments (37)

  1. Is there such a thing as an association relationship in PHP? Such that a classB can contain an instance of classA as a property inside of classB?

    What you would call containment in other OO languages such as Java or C#.
    If not, how could you accomplish this is PHP?

    class A{
    // properties
    public string $name = "";
    }// end class A

    class B{
    // properties
    public $obj = new A();
    }// end class B

  2. That last part was tricky, because it feels like it shoul of been parent not self, sense it was defined in the parent class, but then returned in the extended class.

  3. Construct is magic method? So I need another method to supply mana potions to it, thanks.

  4. I don't understand the point of using the magic __get() and __set() methods on the private class variables. In the previous lesson, he says that you use the private declaration to restrict variable access to within the class, which makes total sense. But then, he goes on to use these magic methods and completely overrides the reason for making them private in the first place! He's essentially made them public.

    I could see using these magic methods to remove the boilerplate code for writing getters and setters, but I don't understand why you're using them to expose private variables outside of the class. Am I missing a fundamental point here?

  5. so i tried doing:
    $tom = new Person('Tom' , 'abc' , 'm');
    $tom -> SayHello();
    it gives me an error: too few arguments supplied for SayHello, expected 3 suplied 0.
    i thought the entire logic behind doing all this was to avoid having to re-write name,lastname,gender everytime?

    ok i found the answer myself, and im keeping this comment for anyone who might run ino the same problem in the future, when you define the SayHello function in your class, u gotta keep the argument list empty cz if u don't it will expect them even if the program doesn't really need them, what i did initially was this:
    SayHello($name ,$lastname , $gender)
    changed it to
    and it works now xD

  6. Thank you! I've been reading/researching OOP and your video put it all together for me. I especially liked that you showed the related errors, just being familiar with those will make created solid code easier. Can't wait to check out your other videos.

  7. Hi, I am did not understood one part: 1:04:41. You have 2 classes, none of classes have static method.
    When you want get smth Class usually we use echo $object->parameter of metchod, and this Employee:: calls static parameters or methods, is it right? I get lost here, why you use this syntax Emplyee::. is it because it is constant?

  8. Thanks for the video. Coming from a c# background I needed a refresher on php’s take on oop. Just one point, static declarations are simply shared values between different instances of the class. So you could in your constructor reference the static property, (let’s say it’s called add with default value 0), with add++. Each time an instance of that class is created, it will remember the value. You can’t do this with normal properties as they always default to their original value. Maybe php is different, but I wouldn’t have thought so.

  9. Awesome video. I've been out of the PHP loop for a few years now and this was an excellent refresher and learning experience. Thank you!

  10. Thanks for this great video. I could understand every word as your style is smooth and simple. I just wanted to know what kind of code editor you use because I see it's great. Thanks in advance.

  11. A question that popped to my head is that, the __construct method is a public function. Nevertheless, when the Person class was extended by the Employee class, in the __construct method for Employee, the __construct method of Person class was called statically. Shouldn't that cause an error?

  12. Hello peter, thanks for the amazing tutorial, made my concepts clear however i have one question
    you called return self::$bloodType? wouldnt it be parent::$bloodType?
    i tested both and it outputs the same result. so whats the recommended option self or parent considering your example above

  13. Hi Nice video helped me alot.But i have a question in getter and setter method.My question is what is the advantage of using a member of class private if it is accessible with getter and setter instead make them all public??

  14. Why you have to type $this -> $firstName = $firstName; I don't get this part? $firstName is equal to it self?

  15. Great tutorial. But your text is too small for iPad, mobile etc, very hard to distinguish what you are typing, your theme doesn't help, that's why VS Code is so great for tutorials. I am not criticising, it looks a great tutorial, but unfortunately the syntax is just ineligible.

  16. Man you have no idea how clearly i am able to understand you compared to anyone else man. 101/100. Thank you!

Comments are closed.