PHP Abstract Classes & Methods - Full PHP 8 Tutorial

Поділитися
Вставка
  • Опубліковано 18 вер 2024
  • In the previous lesson we covered inheritance, in this video, you'll learn about abstract classes & abstract methods. Abstract classes use inheritance so if you have not watched the last lesson about inheritance please make sure to watch that first since the same rules apply to abstract classes.
    SOME OF THE WAYS YOU CAN SUPPORT THE CHANNEL
    👍 Smash the like button
    🤝 Subscribe to the channel & turn the notifications on
    💬 Post comments, any feedback is greatly appreciated
    ⭐ Become a Patreon: / programwithgio
    THANK YOU!
    LESSON 2.10
    Course Outline - github.com/gge...
    Course Playlist - • Learn PHP The Right Wa...

КОМЕНТАРІ • 99

  • @junelajambaro9215
    @junelajambaro9215 3 роки тому +21

    If I'm not in any rush, I don't skip ads to support your channel. I'm not gonna surprise if this channel will grow more and more in the near future. You're now one of my favorite instructors here in UA-cam. :)

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому +5

      Thank you so much, happy to hear that & I appreciate the support

    • @aleksandrkanygin2672
      @aleksandrkanygin2672 2 роки тому +4

      Oh my god, completely forgot about ads, from now i'll turn off the adblock for this channel

  • @sheikh4218
    @sheikh4218 Рік тому +5

    I watched many php related courses but without any doubt i want to say that your course is best php course on entire youtube
    thank you for providing us such a valuable content
    now i understand much more in oop because of you
    and i want that you make a course on laravel also
    i would be very grateful if you did

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +2

      Thank you 🙏. I plan on making Laravel course, don't have the date yet though

  • @RushAlvarado
    @RushAlvarado 2 роки тому +5

    If I pass the job interview, I'll buy you something. Thank you so much so much for these videos.

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому +10

      That's very kind of you but you passing the interview will be more than enough for me. Best of luck, I'm sure you'll ace it 🙌

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

    Best php class and oop tutorial

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

    Clear explanation. I am learning couple of things from your every videos. Thanks much

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

      You're welcome, happy to hear that my videos are helpful 🙌

  • @shehiali9889
    @shehiali9889 3 роки тому +4

    great tutorial, pls upload more complex OOP PHP features

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

      Thank you. We're moving to more complex & advanced PHP with each new lesson 👍

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

    Great lesson. I'm really counting on more exposure. To really know when to implement abstract classes or not. This is technical stuff man. Thanks Gio

  • @nataliadrause924
    @nataliadrause924 Рік тому +1

    I can't thank you enough for these amazing series! I've been already using so much knowledge from it in my work. Huge thanks!

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

      Super happy to hear this, thank you & keep on rocking 🙌

  • @johongirrahimov2343
    @johongirrahimov2343 3 роки тому +9

    ***SUMMARY***
    - Abstract class is the class that has at least one an abstract method
    - Abstract class does just declare the abstract method but does not implement it. In other terms, it knows what of the abstract method but not how of the abstract method
    - Child class method knows how the abstract method
    - Rule for using the abstract method:
    -. The signature of the abstract method and child class method must be the same however the abstract method can have additional arguments.

    • @faramarztayyari3734
      @faramarztayyari3734 2 роки тому +2

      I will add :
      - Abstract class can have both abstract method and normal method

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

      - Abstract method can't declare as private

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

      - The abstract method can have additional arguments so long as they have default values.

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

      abstract classes can implement static methods

  • @CodeWithAbirOfficial
    @CodeWithAbirOfficial 9 місяців тому

    Thank you, @Gio! I now grasp the concept of abstract classes better than I did in college.

  • @sujanmiya4514
    @sujanmiya4514 Рік тому +1

    Great tutorial

  • @Curiosity-7-
    @Curiosity-7- 2 роки тому +1

    Hi sir
    everything is just perfect and up to the mark.
    just one suggestion as most of us make notes it will be very helpful if imp point you mention in between could be available as summary in one frame so that we can take snap of it rather than typing by our self.
    Again thanks for what u r doing GBU🙂🙏.

  • @peterpardo4138
    @peterpardo4138 11 місяців тому

    Thank you for this! Currently watching this course everyday. Again, thank you!

    • @ProgramWithGio
      @ProgramWithGio  11 місяців тому

      You're very welcome, thanks for watching

    • @peterpardo4138
      @peterpardo4138 11 місяців тому

      @@ProgramWithGio I remember someone suggesting if you can create a "composer tutorial", and I will gladly support that in case you plan in creating one. Thank you again! I really appreciate it.

  • @karam0101
    @karam0101 2 роки тому

    Thank you very much Gio 👍👍👍👍

  • @CarlosOrtiz-sz2pp
    @CarlosOrtiz-sz2pp 2 роки тому +1

    Very interesting lesson, thank you

  • @Vitalii-m6r
    @Vitalii-m6r Рік тому

    This course is awesome, to say the least. Thanks!

  • @omaryahia
    @omaryahia 11 місяців тому

    amazing as always

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

    Great one man!!! Really cleared a lot of things for me!

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

    Great PHP tutorial, thank you so much!

  • @Armando-px8hi
    @Armando-px8hi Рік тому

    Thank you so much Gio , I said and will keep saying that you are the best who knows everything about PHP. I have one question, is open-closed principle often used in oop or not so?

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +1

      Thank you. Yes that is one of the principles of OOP in general, not specific to PHP

  • @brainyworld2184
    @brainyworld2184 3 роки тому +3

    Thanks, well explained.
    What is the major difference between Abstract and Interface?

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому +3

      Thank you. The next video will be about interfaces & I'll explain the differences. The main difference is that abstract class can have implementations (non-abstract methods) while interface only contains method definitions. The next video will have more details.

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

      @@ProgramWithGio Once again thanks for the awesome tutorials

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

      @@brainyworld2184 you're welcome. I'm glad it's helpful 🙌

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

      ​@@ProgramWithGio Your clear explanation of basic concepts keep me coming for your tutorials

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

      @@brainyworld2184 Very happy to hear that. Those basic & small details are pretty important :)

  • @eduardozinhani2056
    @eduardozinhani2056 2 роки тому

    Please turn on subtitles!
    thanks for the tutorials

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому

      Subtitles are on, it's just sometimes UA-cam doesn't generate them on some videos.

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

    Thank you!!!🙏

  • @memack101
    @memack101 2 роки тому

    Thank you.

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

    thank you!

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

    Hi, isnt it overloading instead of "overriding" at 7:47? As I know, if you use same method in child class but pass different parameters, its overloading not overriding. But is it different in PHP?

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +1

      Hello. PHP does not support method/function overloading. Overloading is when you have 2 functions with same name but different arguments and it gets called based on the arguments passed. When you use inheritance you are overriding the method.

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

    why do we need to create instances of Field and Boolean and display them if we don't need them? we can as well ignore creating the instances and display the rest? i need explanation on this, thanks

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

      Just as an example, if you watch it little bit more we change the Field & Boolean to abstract classes & remove the instantiation part.

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

    can abstract class inherint another class as an abstract ? and another thing you say about override default values the render function in the parent class has argument which is $name.?

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

      Yes abstract class can extend another class. I don't think I understand the question about default value, can you rephrase?

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

    its a perfect series go ahead do u have any courses on udemy u the best

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +1

      Thank you. No, I don't have courses on Udemy

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

    Thanks again! Oh, it looks like i am the first commenter.

  • @Netpilation
    @Netpilation 3 місяці тому

    this is some nect level stuff

  • @user-mo3cw6go7c
    @user-mo3cw6go7c Рік тому

    I think that abstract class can also be used as a kind of documentation that is embedded directly in the code instead of writing it as comments on the code

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

      Hmm, not exactly sure what you mean

    • @user-mo3cw6go7c
      @user-mo3cw6go7c Рік тому

      @@ProgramWithGio
      I mean that if another developer sees the code, he can, according to the abstract class, understand how the rest of the code is structured and what it means

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +1

      @@user-mo3cw6go7c I don't see that as a good usecase to be honest. If you want to enforce something you can use interfaces to set a contract. Abstract class shouldn't replace a documentation then it just adds extra class for no apparent reason. Maybe I'm missing something.

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

    Gio is so blazing fast that watching in 0.85 feels like a must 😂

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

      😂😂. I'm so sorry haha. I've made mistakes while editing. I am usually fast while talking but I also cut out empty spaces while editing making it seem like I don't breathe 😁

  • @lairotuT-Tutorial
    @lairotuT-Tutorial 6 днів тому

    Great!!!
    But I don't understand why in your example we could not simply make the rendering more flexible to be used on every of the childs to reduce duplication.
    public function renderField($type, $name) {
    return

    • @ProgramWithGio
      @ProgramWithGio  6 днів тому

      You could but then what if you have Select or other type of fields that are not . You'd have to override the method. So another way would be to have InputField as base class which has the render method with and then rest of the input type fields would extend this. Select field would extend the base field class & have its own render.

    • @lairotuT-Tutorial
      @lairotuT-Tutorial 5 днів тому

      @@ProgramWithGio Yeah, that sounds clear to me. Indeed that is a bit what I meant. For me it sounds great to get rid of as many HTML-stuff and build my page with PHP-objects but is this really usually done or is it only a kind of playground?

    • @ProgramWithGio
      @ProgramWithGio  4 дні тому +1

      It depends, if you are building some kind of library or a toolkit then maybe. I personally try to keep the UI components inside front-end & avoid using PHP for it unless I need some dynamic generation, even then I try to create an API for it so that I can pass info from PHP to view & have the view generate the proper html component

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

    When I an trying to use the Property Promotion Attribute PHPStrom 2020.1 throws error: semicolon expected.
    I have PHP8 installed locally, but can't set PHP language level above 7.4 in PHPStorm Settings.
    Is there a possiblity to overcome this?
    Excuse my poor english, I am Dutch :-)

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

      PHPStorm 2020.1 does not have support for PHP 8, you will need to update the phpstorm version. It was added I think in 2020.3 or 2021.1

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

    When to use abstract classes and when interfaces?

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +1

      Next video is about interfaces and that should help answer that question. In general if you need polymorphism you would use interfaces. Abstract classes for inheritance if you need to build a hierarchy in a way

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

      @@ProgramWithGio Thank you! Clear answer!

  • @rosarioveneruso9928
    @rosarioveneruso9928 2 роки тому

    Hi Gio , could u turn on the subtitles for this video?

    • @rosarioveneruso9928
      @rosarioveneruso9928 2 роки тому

      Also , did you mention the heredoc html syntax in previous videos?

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

      It should be automatic, I'll check what's up with this video, maybe UA-cam wasn't able to detect it. There is video about heredoc syntax in first section of the course together with string data type

  • @truthteachers
    @truthteachers 2 роки тому

    Hi Bro, I am still having problems with your code samples. In the previous lesson the src folder and this lesson is different. So i follow and override the old src folder. That is ok, if and only if you dont go back to the older contents at some point in another video. In some cases you do that and I had to scramble to create the old codes. I hope its going to happen again.

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому

      Some lessons don't have source code like this one. If the lesson is mostly theory then it doesn't have branch in the repository. Ones that do you will find the link in the description to the specific branch. Most lessons in 1st & 2nd sections don't have associated branches. You can always DM me on Twitter and I'll be happy to help you & clear up any confusion 👍

    • @truthteachers
      @truthteachers 2 роки тому

      @@ProgramWithGio That is what I decided. Done testing code. Just watch n move on. Less leg work.

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому

      @@truthteachers yea, third section is where you'll need to code along and there are branches & source for them available.

  • @rxxt-sh1vj
    @rxxt-sh1vj 3 роки тому

    Bro is it necessary that an abstract class should have atleast one abstract method ??

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

      No, you can have abstract class without abstract methods. It's just if you have at least one abstract method then class has to be abstract also.

    • @rxxt-sh1vj
      @rxxt-sh1vj 3 роки тому

      @@ProgramWithGio Sounds Nice :D

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

    The more abstract OOP gets, the dumber I feel 😵‍💫

    • @ProgramWithGio
      @ProgramWithGio  Рік тому +1

      I feel you. I've felt the same way when I was starting out, so don't worry about it. Keep practicing & stay consistent and you'll get through it 💪

  • @dilshan6377
    @dilshan6377 6 місяців тому

    start 2024-03-04, today 3-19 still in here i have lot of things to know.

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

      Keep going, its not a sprint, its a marathon. Enjoy the process