14: Abstract Classes in OOP PHP | Abstract Explained | Object Oriented PHP Tutorial | PHP Tutorial

Поділитися
Вставка
  • Опубліковано 18 вер 2024
  • In this OOP PHP tutorial, I will let you know about abstract classes in OOP PHP. Abstract classes in PHP are used to help us create behavior similarly to interfaces, but they do serve a different purpose as well.
    ➤ MEET OTHER AWESOME PEOPLE!
    FollowAndrew
    Channel: / followandrew
    With over 20 years experience, Andrew is creating web & front-end design tutorial videos!
    ➤ GET ACCESS TO MY LESSON MATERIAL HERE!
    First of all, thank you for all the support you have given me!
    I am really glad to have such an awesome community on my channel. It motivates me to continue creating and uploading content! So thank you!
    I am now using Patreon to share improved and updated lesson material, and for a small fee you can access all the material. I have worked hard, and done my best to help you understand what I teach.
    I hope you will find it helpful :)
    Material for this lesson: / lesson-material-42361704

КОМЕНТАРІ • 104

  • @davidsimonovic6471
    @davidsimonovic6471 4 роки тому +42

    I would love to see a OOP PHP full site video after the oop tutorial. My morning starts with a coffe and lesson here. Keep it going.

    • @JoshuaTMagee
      @JoshuaTMagee 4 роки тому +7

      I second this, and would be more than happy to pay money for it. Ideally a full website build that includes OOP PHP coding solutions for user authentication, password recovery, user account dashboard, and shopping cart/checkout. Thank you!

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

      Guys , I am also learning PHP and it is going tough for sure, but don't be deceived by videos. The videos are there to give you the theory, the concepts , but 80% of being a successful programmer is just coding on a daily basis whether it is 45 min or 8 hours , and actually do the code yourself . You can practice with simple things, eventually you will realize it is all repetitive. You don't need to a whole tutorial on building a shopping cart to build one, just start actually putting in the work..

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

      @@lebedev9114 Hey bro do you ever know why the extends thing is not working ? when i make a class for example and then make another class and extends from the first class in another file it's giving me an error if i don't include the file of the parent class in the file of the second class>>> without including the file it's not extending any thing!!

    • @lebedev9114
      @lebedev9114 4 роки тому

      @@abdulrahmann1621 bro check the autoload tutorial and make sure you made it correctly. Otherwise each time you make a new class file you have to use 'include' function to include the other class you plan to extend.

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

    I love Dani's tuts because he speaks a neutral dialect of English (so many computer tuts come out of India and the people speaking have a very poor grasp of English and they are too difficult to uunderstand) and he gives very helpful info. Dani is one of the best channels on youtube for programming!

    • @Michael-lo3ht
      @Michael-lo3ht 7 місяців тому

      Totally agree. They also speak English at the same speed they're used to speaking. So it's impossible to understand all the words. On top of that, trying to pick out technical details multiply the problem. This is one channel I am hooked on.

  • @andreitodosi
    @andreitodosi 4 роки тому +44

    Always wandered what the Peaky Blinders are up to these days..

  • @bgray79
    @bgray79 4 роки тому +8

    I just discovered that the order in which classes are included is important. I haven't heard you mention that yet. It took me a few minutes to figure out why I was getting an error, as I had been using a separate header, index, footer page. After reducing it down to what you have here, I still got an error stating that the "Visa class could not be found referenced in BuyProduct". Then I moved the include abstract statement to the top, and voila! It works.

    • @derpspopovich1579
      @derpspopovich1579 4 роки тому

      oh fk thanks for this.been trying to solve this error for a minute. the include abstract statement should be first at the top.

    • @ozanulutas3334
      @ozanulutas3334 4 роки тому

      That's because the computer read the codes from start (top of the file) to finish. If you woludn't include the abstract classes -which will be used(extended) later- first it throws an error about not finding the referenced class.

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

      if need to setup them are required or what s going to happen with autoloader :) .... Let see one step at a time :) this is coding hahah

  • @onee
    @onee 2 роки тому +7

    If you're wondering what abstract classes are (like me), and WHY we use abstract classes, go to 8:41. I've been looking up and down the internet for someone to explain this in simple words to me, and finally found it. For some reason the other people I stumbled upon all make it unnecessarily overly complex. Especially if they intend to teach this to beginners.

  • @wadiibounenni4848
    @wadiibounenni4848 6 місяців тому +2

    Deep Theory + Practical Life Examples + Clear Explantations = Dani :)

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

    I've watched both your PHP playlists and followed every step - it's really helped me understand PHP on a better level than sites like Codecademy thanks bud!

  • @MuhammadAli-ve7mt
    @MuhammadAli-ve7mt 2 роки тому +4

    I'm going to leave this here in case someone finds the use of abstract classes confusing even after the explanation.
    Consider an abstract class for an Employee. Each employee is going to have common attributes such as first name, last name, address and so on, but there will be some attributes that differ.
    Now, let's say we are talking about an educational institution. There can be "permanent" or "visiting" employees. Permanent employees get paid an equal amount every month, so their salaries can be defined in their own "PermanentEmployee" class which extends the main "Employee" class. And for visiting employees, the salary can be defined in a class called "VisitingEmployee" which also extends the main Employee class.
    abstract class Employee{
    protected $firstName;
    protected $secondName;
    protected $address;
    }
    class PermanentEmployee extends Employee{
    private $salary;
    }
    class VisitingEmployee extends Employee{
    private $hourlySalaryRate;
    }
    In this way, we get to use the common attributes through the child class, as well as attributes of their own.

  • @m_lk9434
    @m_lk9434 4 роки тому +1

    Started watching your videos to learn a few concepts that i was uncertain of. And now im watching all the videos just because I love they way you speak😂😂❤️
    But I must appreciate, the explanation is convincing, they way you present the content is awesome. Good luck❤️

  • @4english21
    @4english21 4 роки тому +1

    you'd be my favorite teacher. the way you explain stuff is so clear and that's perfect, maybe i couldnt say the same for the examples though. keep up the good stuff anyway.

  • @dzintarsmagons
    @dzintarsmagons 4 роки тому +1

    Thank you for the effort that you put in making these videos. Your way of clarifying things makes this way easier.

  • @binsarharseno
    @binsarharseno 4 роки тому

    I think by just listening your explanation like a podcast i will understand what is abstract class is, very clear, thank you

  • @asuUcKa
    @asuUcKa 4 роки тому +1

    Wow 3 days of school = 1 of your videos, (i need to put more attention to class) but i learn better here.

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

    Really Good Idea of Naming Files!!! I will Follow this!!

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

    Simple and well explained. Thanks.

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

    Dani for a person whose first language is not English, you have really a masterful command of the language. Your accent sounds very natural, i think you must've spent a lot of time in the USA to master our crazy accents. I was an ESL teacher for many years and I wish I could bottle your accent and give it to my students. How long were you in the USA and what part of the country? I'm guessing the midwest or California.

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

    Finally a clear explanation of abstract classes

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

    I'm here! 😎 Great video, just posting a comment to show some support! Keep up the good work. 🤙

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

    the best oop php tutorial I've come across. Clarity!!!!

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

    Very precisely elaborated. Would like to see laravel tutorial too. Thank you

  • @ademineshat
    @ademineshat 5 років тому +4

    Will we build some kind of Project including things we've learned?
    Anyway thanks
    Edit: Best video sofar including Voice quality, video and how you placed the things :)

  • @vlatkoviamkd
    @vlatkoviamkd 4 роки тому

    This is the first video that i have seen from you but the way you explain things are one of the best i have seen and i have been watching many of Udemy and youtube courses . Respect, keep on the good work. Subscribed

  • @bilalbeny4172
    @bilalbeny4172 8 місяців тому +1

    thank you for this amazing video :), I love your way in explanation and simplify things, keep going🙏

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

    That was an awesome set of videos. I learned a lot from you thank you.

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

    this course is amazing, amazing teacher. And also its a strange feelin to learn all of this from Ellon Musk. HAHAHA just kidding, thank you a lot for all of this classes. Really helped. The world need people like you!

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

    I really love all videos and the method used to teach, Great job Bro

  • @MiriamAraújo-y1x
    @MiriamAraújo-y1x 10 місяців тому +1

    Thank you so much for making this video.

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

    Just like the interfaces video, this is great! Clear explanation with real world use case. Thank you!

  • @jeesambo
    @jeesambo 5 років тому +1

    Thank you so much. Your presentation is extremely perfect. thanks alot for the tutorial. Fly high.

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

    One other thing that you can do in extending class is you can play the callback like in BuyProduct Class
    public function visaPayment(){
    $callback = parent::visaPayment();
    $callback.= " from buy product."
    return $callback;
    }
    output will be "Perform a payment from buy product."

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

    Good to see a detailed OOP series in PHP with awesome real life examples. Thank you @Dani Krossing

  • @odunladeoluwaseun7880
    @odunladeoluwaseun7880 5 років тому +1

    Nice tutorial on abstract. thanks for the usually quality delivery. please I need a revision on using traits

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

    Very nice presentation.thanks

  • @acavaelnick
    @acavaelnick 4 роки тому +1

    Great series of videos dude!
    Really helping me out to understand this concepts, thank you so much!

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

    The best lessons dani keep it up. I really prefer this youtube because it's free and well explained. 💞💞

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

    Thank you for a great explanation! That really cleared up the fuzzy pieces for me on abstract classes and their application.

  • @Michael-lo3ht
    @Michael-lo3ht 7 місяців тому

    I love the videos. I will have to digest more of the interfaces again, as it took too many turns and twists later and lost me. I have to say I'm totally lost on this one. I guess when I hear abstract I guess I expected the names to be abstract or something. So far it just only looks like you extended a class. I will have to maybe find something that might fill in the blanks for me. Sorry, that I didn't quite pick it up for some reason.

  • @tryharder927
    @tryharder927 5 років тому +1

    i will watch all of your videos
    love it man

  • @generalpolkovnik4039
    @generalpolkovnik4039 5 років тому +1

    thank you all your videos helped me

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

    Is it possible to have a method in your abstract class that calls an abstract function that is implemented in the child class? I'm trying to do this but keep getting errors.

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

    Easy and for the whole family

  • @AbhishekBiz
    @AbhishekBiz 4 роки тому

    Dude you have the great style of coding and fashion both.

  • @ProgrammingwithPeter
    @ProgrammingwithPeter 5 років тому

    Your tutorials are great, flawless !

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

    tysm for this great content Mr.Dani !

  • @tuananhdo1870
    @tuananhdo1870 5 років тому +3

    Could you make tutorial on namespace in PHP?

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

    Some important rules:
    1. One class can extend only one abstract class (PHP doesn’t support multiple inheritance).
    2. Any class with at least one abstract method must be declared abstract.
    3. Abstract classes might contain concrete methods (rules or logic already implemented), interfaces don't have any implementation (it is just a prototype declaring the signatures of the methods - return type, parameters), it's just a contract that must be followed by implementing classes which will supply its own implementation.

  • @nikolav6350
    @nikolav6350 5 років тому

    THANK YOU FOR THIS OPP LESSONS YOU ARE THE BEST!

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

    Can we say that abstract and interface almost do the same? I think I see that we can do the same with interface and interface more useful. Because what if you had more classes which contains other payment types like Paypal? Does it mean I need to create another abstract class for Paypal and extend it in new byproduct class? It is already sounds confusing :D
    Very clear communication.

  • @palyons4817
    @palyons4817 4 роки тому

    You're videos have been a great help, many thanks!

  • @adilsaeed5381
    @adilsaeed5381 4 роки тому +1

    Uncaught Error: Class 'visa' not found in C:\xampp\htdocs\oop\classes\buy.abstract.php:4 Stack trace: #0 C:\xampp\htdocs\oop\abstrction.php(2): include() #1 {main} thrown in C:\xampp\htdocs\oop\classes\buy.abstract.php on line 4
    whts the solution i did the same code only names are diffr

  • @gtggj6851
    @gtggj6851 4 роки тому

    You can run most of examples in the windows console using php - f name.php .

  • @98toxic1
    @98toxic1 5 років тому

    You're the man! Thanks for all you do!!

  • @tuncaybasak4953
    @tuncaybasak4953 4 роки тому

    So, in the MVC design pattern the MODEL class is declared with ABSTRACT? (as it is only extended by VIEW and CONTROL classes and never called by a constructor)

  • @dinushasathyajith5049
    @dinushasathyajith5049 5 років тому

    Great video. Thanks Daniyel 😁😁

  • @Oxmond
    @Oxmond 5 років тому +1

    Good job! 👍 && hat == "awesome"

  • @Urti
    @Urti 5 років тому

    You are great ! please create laravel course.

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

    You look like a movie star on a vacation in Europe with that hat and glasses.

  • @roiunger7796
    @roiunger7796 5 років тому +1

    Beautiful hat my brother

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

    Why do some insist on never wrapping include or include_once with parenthesis? I mean, it's a function, so it looks more correct as include('file.php');

  • @josemfcheo
    @josemfcheo 4 роки тому

    Thanks man!

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

    Dani, how did you learn PHP to such a high level?l I studied software engineering in college and I don't have the level of mastery of PHP that you have.

  • @Maccelerate
    @Maccelerate 5 років тому

    Great video!

  • @karthickm2623
    @karthickm2623 4 роки тому

    What suppose multiple class I need use abstract class "implement" not required here ?

  • @abdulrahmann1621
    @abdulrahmann1621 4 роки тому

    hello mmtuts do you ever know why the extends thing is not working ? when i make a class for example and then make another class and extends from the first class in another file it's giving me an error if i don't include the file of the parent class in the file of the second class>>> without including the file it's not extending any thing!!

  • @augischadiegils.5109
    @augischadiegils.5109 3 роки тому

  • @RK-gm4pd
    @RK-gm4pd 5 років тому

    Great video. Thanks to author!
    All these OOP it's just total mess and gibberish. I never understood why people invent tons of unnecessary rules and frames for it's life. JS forever! Only prototype ))

    • @daniele5692
      @daniele5692 4 роки тому

      «I never understood why people invent tons of unnecessary rules and frames for it's life»
      yes, JS hasn't unnecessary rules....

  • @kubulus7868
    @kubulus7868 5 років тому +1

    do you use php on the daily basis? I ask, 'cause php is gradually being replaced by node and other js things.

    • @kubulus7868
      @kubulus7868 5 років тому

      @@jasondavies3772 Yeah I do, and I am even on php side, but I just noticed this trend

  • @YCode_
    @YCode_ 5 років тому

    gooood job thank you

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

    Please how do i run mysql logics with getters and setters

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

    you look like Elon Musk haha btw thank you so much your video are very helpful to me

  • @youssefdaoud7265
    @youssefdaoud7265 5 років тому +2

    Mmtuts can you please create a customer queing system

  • @anewworld5201
    @anewworld5201 4 роки тому

    Which is base class and derives class

  • @danielmobbs5096
    @danielmobbs5096 4 роки тому

    love the hat!!! :D

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

    If you're coming across an error 'Uncaught Error: Class 'Visa' not found' include 'include(__DIR__ .'/../abstract/paymenttypes.abstract.php');' in your BuyProducts.class.php, no need to include this on the index page also.

  • @kushalchavan1
    @kushalchavan1 5 років тому

    Please start tuts on php laravel coz we love your explaination 😉 thanks for awesome videos

  • @siriusgd4753
    @siriusgd4753 4 роки тому +1

    I still get confused as to how an abstract class is any different from a simple extended class.

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

      The functionality is basically the same, however as explained in the vid the main difference is that abstract classes and functions/methods can't be instantiated (you can't create the objects from them like you can from regular ones). You can think of it as a chunk of a common reusable code that you never gonna use on its own, but only as a substrate or a base class to extend to your other classes that all should extend the properties and methods from this abstract one.

    • @abdulrahmann1621
      @abdulrahmann1621 4 роки тому +1

      @@dusanknezevic4028 Hey bro do you ever know why the extends thing is not working ? when i make a class for example and then make another class and extends from the first class in another file it's giving me an error if i don't include the file of the parent class in the file of the second class>>> without including the file it's not extending any thing!!

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

    nice hat bro

  • @perianka
    @perianka 4 роки тому

    where are you from?

  • @nahabat9
    @nahabat9 5 років тому +1

    please make a laravel series!!!!!!!!!

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

    08:26

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

    You look like Elon Mask with that hat 😀

  • @dhrubavideos
    @dhrubavideos 4 роки тому

    U very cleverly just touched it but not elaborated with example

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

    Yet another tutorial showing absolutelly basic usage of abstraction. And 99% will ask themself why would they need abstract classes at all. Will downvote it because you people just copy each other content.

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

      There are a couple of things I'd like to address in regards to your comment...
      Firstly, I'm going into great detail in my video to explain what abstract classes are and how they work. And accusing UA-camrs who are only here to try and help you, of "just copying each others content", is both disrespectful, and an INCREDIBLE entitled behaviour towards FREE content.
      This link took me 10sec to find on Google, which explains examples of abstract classes and when to use them in detail: www.quickstart.com/blog/when-and-how-to-use-abstract-class-and-interface/
      The issue here is not "UA-camrs being lazy by copying each other". It's you looking in the wrong places or not understanding it when you find what you were looking for, and then taking your frustrations out on UA-camrs who provide you with FREE educational content.
      You didn't pay for a Udemy or Lynda course... You are here on UA-cam watching FREE content. You are grossly misunderstanding what "rights" you have, when you are trying to 'smite' a content creator who provides FREE educational content.
      I recommend going to a paid service like Udemy, since over there you ACTUALLY have the right to complain about it not being good enough for you.
      If I see another entitled comment from you, I will block you.

  • @king_israel6
    @king_israel6 5 років тому

    Nice hat and video but please I need a huge favor from you😭😭😭

    • @roiunger7796
      @roiunger7796 5 років тому

      Is everything all right? Maybe I can help you?

    • @king_israel6
      @king_israel6 5 років тому

      @@roiunger7796 OK I wanted some favour like how to add download link to files and also the php comments video have a little goof. The comments didn't enter the database then again I wanted a pagination page with links😭😭

  • @myvishan
    @myvishan 4 роки тому

    PRO TIP: turn the video at x1.25 speed. Thank me later.

  • @cd78
    @cd78 5 років тому +1

    OOP = overly convoluted nonsense. Learn procedural instead..