PHP Abstract Classes & Methods - Full PHP 8 Tutorial

  Рет қаралды 26,163

Program With Gio

Program With Gio

Күн бұрын

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 жыл бұрын
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 KZbin. :)
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
Thank you so much, happy to hear that & I appreciate the support
@aleksandrkanygin2672
@aleksandrkanygin2672 2 жыл бұрын
Oh my god, completely forgot about ads, from now i'll turn off the adblock for this channel
@sheikh4218
@sheikh4218 Жыл бұрын
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 Жыл бұрын
Thank you 🙏. I plan on making Laravel course, don't have the date yet though
@RushAlvarado
@RushAlvarado 2 жыл бұрын
If I pass the job interview, I'll buy you something. Thank you so much so much for these videos.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
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 жыл бұрын
Best php class and oop tutorial
@thevipinchand4690
@thevipinchand4690 3 жыл бұрын
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 жыл бұрын
great tutorial, pls upload more complex OOP PHP features
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
Thank you. We're moving to more complex & advanced PHP with each new lesson 👍
@Zubbee
@Zubbee 2 жыл бұрын
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
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
With practice & experience you'll know
@nataliadrause924
@nataliadrause924 Жыл бұрын
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 жыл бұрын
***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 жыл бұрын
I will add : - Abstract class can have both abstract method and normal method
@abdussukkur9080
@abdussukkur9080 2 жыл бұрын
- Abstract method can't declare as private
@godmansarah
@godmansarah 2 жыл бұрын
- The abstract method can have additional arguments so long as they have default values.
@oghenevwefepeace2501
@oghenevwefepeace2501 2 жыл бұрын
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.
@ProgramWithGio
@ProgramWithGio 9 ай бұрын
That's great, happy to hear 💙
@sujanmiya4514
@sujanmiya4514 Жыл бұрын
Great tutorial
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Thank you 🙌
@Curiosity-7-
@Curiosity-7- 2 жыл бұрын
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🙂🙏.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Hello. Thank you & I'll try my 💙
@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 👍👍👍👍
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
You're welcome
@CarlosOrtiz-sz2pp
@CarlosOrtiz-sz2pp 2 жыл бұрын
Very interesting lesson, thank you
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
Glad you like it, thank you 🙌
@Vitalii-m6r
@Vitalii-m6r Жыл бұрын
This course is awesome, to say the least. Thanks!
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Thank you 💙
@omaryahia
@omaryahia 11 ай бұрын
amazing as always
@ProgramWithGio
@ProgramWithGio 11 ай бұрын
Thanks 💙
@alazark94
@alazark94 Жыл бұрын
Great one man!!! Really cleared a lot of things for me!
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Glad to hear it, thank you
@miroslavtoikin
@miroslavtoikin Жыл бұрын
Great PHP tutorial, thank you so much!
@ProgramWithGio
@ProgramWithGio Жыл бұрын
Thank you 💙
@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 Жыл бұрын
Thank you. Yes that is one of the principles of OOP in general, not specific to PHP
@brainyworld2184
@brainyworld2184 3 жыл бұрын
Thanks, well explained. What is the major difference between Abstract and Interface?
@ProgramWithGio
@ProgramWithGio 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 жыл бұрын
@@ProgramWithGio Once again thanks for the awesome tutorials
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
@@brainyworld2184 you're welcome. I'm glad it's helpful 🙌
@brainyworld2184
@brainyworld2184 3 жыл бұрын
​@@ProgramWithGio Your clear explanation of basic concepts keep me coming for your tutorials
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
@@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 KZbin doesn't generate them on some videos.
@rustem6388
@rustem6388 Жыл бұрын
Thank you!!!🙏
@ProgramWithGio
@ProgramWithGio Жыл бұрын
You are welcome 🙌
@memack101
@memack101 2 жыл бұрын
Thank you.
@ProgramWithGio
@ProgramWithGio 2 жыл бұрын
You're welcome!
@ilya_123__
@ilya_123__ 10 ай бұрын
thank you!
@ProgramWithGio
@ProgramWithGio 10 ай бұрын
You're welcome
@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 Жыл бұрын
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 Жыл бұрын
Thank you. No, I don't have courses on Udemy
@techatival
@techatival 3 жыл бұрын
Thanks again! Oh, it looks like i am the first commenter.
@ProgramWithGio
@ProgramWithGio 3 жыл бұрын
You're welcome :)
@Netpilation
@Netpilation 3 ай бұрын
this is some nect level stuff
@ProgramWithGio
@ProgramWithGio 2 ай бұрын
Glad you like it
@ינוןאלבז-כ1ז
@ינוןאלבז-כ1ז Жыл бұрын
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
@ינוןאלבז-כ1ז
@ינוןאלבז-כ1ז Жыл бұрын
@@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ז 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 7 күн бұрын
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 7 күн бұрын
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 6 күн бұрын
@@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 5 күн бұрын
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 Жыл бұрын
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 жыл бұрын
It should be automatic, I'll check what's up with this video, maybe KZbin 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 жыл бұрын
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 Жыл бұрын
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
When to use Traits, Interfaces, and Abstract Classes in PHP
15:08
Andrew Schmelyun
Рет қаралды 20 М.
МЕБЕЛЬ ВЫДАСТ СОТРУДНИКАМ ПОЛИЦИИ ТАБЕЛЬНУЮ МЕБЕЛЬ
00:20
PHP - Encapsulation & Abstraction -  Full PHP 8 Tutorial
15:23
Program With Gio
Рет қаралды 31 М.
The Flaws of Inheritance
10:01
CodeAesthetic
Рет қаралды 942 М.
Static Properties & Methods In Object Oriented PHP -  Full PHP 8 Tutorial
12:58
Java abstraction 👻
5:30
Bro Code
Рет қаралды 134 М.
PHP Namespace Tutorial - Full PHP 8 Tutorial
20:15
Program With Gio
Рет қаралды 57 М.
PHP doesn't suck (anymore)
10:48
Aaron Francis
Рет қаралды 206 М.
PHP Traits - How They Work & Drawbacks - Full PHP 8 Tutorial
31:41
Program With Gio
Рет қаралды 32 М.
Fundamental Concepts of Object Oriented Programming
9:16
Computer Science
Рет қаралды 905 М.
Abstract Classes and Methods in Java Explained in 7 Minutes
7:00
Coding with John
Рет қаралды 514 М.