#04 PHP Object Oriented Programming Basics - OOP | $this keyword | Quick programming tutorial

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 22

  • @AlishSafarli
    @AlishSafarli 5 місяців тому

    13:34 - you call both the calculate_total method $book->calculate_total, and $book->read() which itself inside doin calculation, what`s the point of calling $book->calculate_total() here?

  • @devbites77
    @devbites77 3 роки тому +2

    Thanks This -> really good.

  • @raymytech
    @raymytech 3 роки тому +1

    Just subscribed, you're good

  • @iangunch6286
    @iangunch6286 3 роки тому +1

    one new subscriber

  • @kulmiyetechnologyWorld
    @kulmiyetechnologyWorld 3 роки тому +1

    Thanks alot bro ♥️♥️♥️♥️♥️

  • @devbites77
    @devbites77 3 роки тому +1

    If I try echo Product::generate_id();
    I get error message Fatal error: Uncaught Error: Non-static method Product::generate_id() cannot be called statically. Have things changed in PHP. I'm using version 8.

    • @devbites77
      @devbites77 3 роки тому

      I got it. The function must be defined as static: public static

    • @QuickProgramming
      @QuickProgramming  3 роки тому +1

      Indeed things have changed. That would have worked a few versions but back

    • @mohamedabid2766
      @mohamedabid2766 3 роки тому

      @@QuickProgramming with php 8 not work
      try this:
      $obj = new Product();
      echo $obj->generate_id();

    • @denisdev4793
      @denisdev4793 Рік тому

      define the method as static function generate_id() , i got the same error

    • @chaddsmith3354
      @chaddsmith3354 10 місяців тому

      Thank you! This has been very helpful!

  • @ab_obada5012
    @ab_obada5012 7 місяців тому

    I think you have a small issue with properties and fields.
    properties should be built as getters,and setters.
    while fields were dedicated for strong data.

    • @QuickProgramming
      @QuickProgramming  7 місяців тому

      I hardly ever use getters and setters. They add unnecessary complexity to otherwise simple code. You can add them if you need to, I cover them in a later video. But personally, I've never needed to use them. They're more important if you're working on an open source project where the general public will be using your classes because you can change filed names without affecting functionality. It's a matter of choice and not a requirement

    • @ab_obada5012
      @ab_obada5012 7 місяців тому

      YES!! thank you very much for the clarification ❤@@QuickProgramming

  • @Mehedihasan-rahat
    @Mehedihasan-rahat 2 роки тому

    extremely poor explanation 😜😜😜😜

    • @QuickProgramming
      @QuickProgramming  2 роки тому +1

      lol its ok, i cant make everyone happy. but learning OOP is important so find a channel with someone you can understand better and continue learning :)

    • @olorunfemiadewale9020
      @olorunfemiadewale9020 Рік тому

      He is totally bluffing.. am sure he envies u 💯