PHP traits in depth with examples - OOP in PHP | Part 9

  Рет қаралды 13,929

The Codeholic

The Codeholic

Күн бұрын

In the following video, it is explained what is PHP Traits, how to create and use them.
Showing examples of:
- Multiple Traits
- Traits and inheritance
- Abstract methods in traits
- How to convert code using traits
- How Laravel uses traits
Introduction to OOP in PHP - • Introduction to OOP in...
Creating classes in PHP - • Creating classes, prop...
Inheritance in PHP - • Inheritance for beginn...
Abstract classes in PHP - • Abstract classes, abst...
Interfaces - • Interface in PHP for b...
Useful links:
www.php.net/ma...
developer.hyvo...
github.com/dwi...
blog.programst...
stackoverflow....
Follow me on social media:
/ thecodeholic
/ thecodeholic
github.com/the...

Пікірлер: 41
@B_G-Y.T
@B_G-Y.T 11 ай бұрын
Very good, congrats.... I'm Brazilian and I liked alot your ability to teatch.
@Manos2505
@Manos2505 4 жыл бұрын
UHHHH G.. with no fear i can say that you are the best tutor ever that i ran into by far. Congrats man, keep up the good work!!! You absolutely deserve more subscribes (y)
@TheCodeholic
@TheCodeholic 4 жыл бұрын
Thank you. It means a lot
@Kai-xc7qu
@Kai-xc7qu 4 ай бұрын
There was a very cool example with the Avengers.Hello from Russia
@saikalbiev7843
@saikalbiev7843 5 жыл бұрын
Really educative. Looking forward for more vids!
@jeffreysacco
@jeffreysacco 5 жыл бұрын
Awesome tutorial. Plain should be spelt as plane.
@TheCodeholic
@TheCodeholic 5 жыл бұрын
Ups.. Thanks for noticing...
@burakkartal2156
@burakkartal2156 4 жыл бұрын
Great, simple and direct to the point. 14:38 when u said " This is absolutely valid code". i was like WHAAAAAA :D
@TheCodeholic
@TheCodeholic 4 жыл бұрын
Excited to read such comments... :D
@shaikhanuman8012
@shaikhanuman8012 4 жыл бұрын
your examples are awesome sir.....love you explanation..
@TheCodeholic
@TheCodeholic 4 жыл бұрын
Thank you
@Protick1994
@Protick1994 3 жыл бұрын
Thank you, this was really helpful, your generous hard work was appreciated. May God bless you.
@TheCodeholic
@TheCodeholic 3 жыл бұрын
Thank you
@pepeback
@pepeback 5 жыл бұрын
Typo: Plane, not Plain. Good video :)
@TheCodeholic
@TheCodeholic 5 жыл бұрын
Thank you Jose
@swastikrocker123
@swastikrocker123 3 жыл бұрын
Thanks to you I am watching the avengers end game again haha. That part liftTheHammer() was just amazing. Keep up the good work. Every scenario and problems using traits was well explained
@azizbeknurmuhammadov7836
@azizbeknurmuhammadov7836 2 жыл бұрын
Thank you. This is an awesome video course.
@TheCodeholic
@TheCodeholic 2 жыл бұрын
Thanks a lot
@SPOKOZE2
@SPOKOZE2 3 жыл бұрын
15:07 why there is "Hello from class AHello from trait A" not "Hello from trait AHello from class A"?
@nemac23
@nemac23 2 жыл бұрын
Looks like syntax error not accounting for order of execution. If the echo in the parent class is changed to a return then it will work fine.
@ivofrancisco357
@ivofrancisco357 3 жыл бұрын
Very good advice my friend. Thank you.
@jesuslagrave3336
@jesuslagrave3336 2 жыл бұрын
This class was great! Thanks. New subscriber.
@kayoscreed
@kayoscreed 3 жыл бұрын
thanks, that was helpful. traits can solve duplication and single inheritance, alright. according to your examples, i have a feeling, that you also can mess things up big time :D ... i might going to use it to deduplicate some code in models.
@jihadabdulrazaq338
@jihadabdulrazaq338 2 жыл бұрын
I have a question, interfaces also accepts multiple inheritance, so what's the difference between interfaces and traits?
@TheCodeholic
@TheCodeholic 2 жыл бұрын
Interfaces only contain the method names and signature. But traits contain method implementations as well.
@adipurnomo5683
@adipurnomo5683 Жыл бұрын
Noted
@Raezon_
@Raezon_ 3 жыл бұрын
I really like this video I m taking your courses to begin some design pattern I hope if you could use a module on yii on your eCommerce project it will be a great thing for now I m doing that to isolate code and doing branches with GitHub for each module separated than the other.
@tambovskya
@tambovskya 4 жыл бұрын
Nice...
@wilwerrodriguez1787
@wilwerrodriguez1787 4 жыл бұрын
perfect thanks
@kesogonzaga2671
@kesogonzaga2671 3 жыл бұрын
Thanks bro
@cristhianjhlcom
@cristhianjhlcom 2 жыл бұрын
In simple words is like a reusable component but for functions? i'm right? nice series of videos btw
@TheCodeholic
@TheCodeholic 2 жыл бұрын
For classes. Their purpose is to achieve multiple inheritance.
@cristhianjhlcom
@cristhianjhlcom 2 жыл бұрын
@@TheCodeholic Thanks, master
@adipurnomo5683
@adipurnomo5683 Жыл бұрын
6:56 I would like use abstract class or interface sir. What difference
@TheCodeholic
@TheCodeholic Жыл бұрын
1. Abstract classes can have implementations of the methods. However interface only defines method signature. 2. You can only extend from one abstract class, but implement multiple interfaces.
@mohammadhosein6847
@mohammadhosein6847 4 жыл бұрын
So traits in php are analogous to interfaces in java?
@TheCodeholic
@TheCodeholic 4 жыл бұрын
No. There are interfaces in PHP also. I am not Java expert, but I think there is no analog of traits in Java.
@mohammadhosein6847
@mohammadhosein6847 4 жыл бұрын
@@TheCodeholic I've just found this question solving the problem: stackoverflow.com/questions/9205083/traits-vs-interfaces Thanks for the reply.
@nick9198
@nick9198 3 жыл бұрын
Lol I literally said out loud while I was watching this 'but you can do this with inheritance', then 2 seconds later you were like 'You might be thinking that you can use inheritance.' That was weird lol.
@TheCodeholic
@TheCodeholic 3 жыл бұрын
Lol. I need to watch that part. Can you tell me the timecode?
@nick9198
@nick9198 3 жыл бұрын
@@TheCodeholic haha 2:13
Everything about PHP namespaces - OOP in PHP | Part 10
16:26
The Codeholic
Рет қаралды 16 М.
PHP Traits - How They Work & Drawbacks - Full PHP 8 Tutorial
31:41
Program With Gio
Рет қаралды 32 М.
МАИНКРАФТ В РЕАЛЬНОЙ ЖИЗНИ!🌍 @Mikecrab
00:31
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 39 МЛН
Nastya and balloon challenge
00:23
Nastya
Рет қаралды 55 МЛН
отомстил?
00:56
История одного вокалиста
Рет қаралды 6 МЛН
escape in roblox in real life
00:13
Kan Andrey
Рет қаралды 74 МЛН
Autoloading in PHP without and with Composer - OOP in PHP | Part 11
16:01
When to use Traits, Interfaces, and Abstract Classes in PHP
15:08
Andrew Schmelyun
Рет қаралды 20 М.
Interface in PHP for beginners with Examples - OOP in PHP | Part 8
20:39
What's new in PHP 8.0
46:09
The Codeholic
Рет қаралды 100 М.
Fundamental Concepts of Object Oriented Programming
9:16
Computer Science
Рет қаралды 905 М.
JAVA DTO Pattern Tutorial | Simplify Your Code
19:12
Amigoscode
Рет қаралды 204 М.
Creating classes, properties, methods - OOP in PHP | Part 1
11:03
The Codeholic
Рет қаралды 21 М.
МАИНКРАФТ В РЕАЛЬНОЙ ЖИЗНИ!🌍 @Mikecrab
00:31
⚡️КАН АНДРЕЙ⚡️
Рет қаралды 39 МЛН