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

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ม.ค. 2025

ความคิดเห็น • 38

  • @Manos2505
    @Manos2505 4 ปีที่แล้ว +6

    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

  • @B_G-Y.T
    @B_G-Y.T ปีที่แล้ว +1

    Very good, congrats.... I'm Brazilian and I liked alot your ability to teatch.

  • @azizbeknurmuhammadov7836
    @azizbeknurmuhammadov7836 2 ปีที่แล้ว +1

    Thank you. This is an awesome video course.

  • @jesuslagrave3336
    @jesuslagrave3336 2 ปีที่แล้ว

    This class was great! Thanks. New subscriber.

  • @Kai-xc7qu
    @Kai-xc7qu 7 หลายเดือนก่อน

    There was a very cool example with the Avengers.Hello from Russia

  • @saikalbiev7843
    @saikalbiev7843 5 ปีที่แล้ว +3

    Really educative. Looking forward for more vids!

  • @shaikhanuman8012
    @shaikhanuman8012 5 ปีที่แล้ว +1

    your examples are awesome sir.....love you explanation..

  • @Protick1994
    @Protick1994 3 ปีที่แล้ว +1

    Thank you, this was really helpful, your generous hard work was appreciated. May God bless you.

  • @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

  • @burakkartal2156
    @burakkartal2156 4 ปีที่แล้ว +1

    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

  • @ivofrancisco357
    @ivofrancisco357 4 ปีที่แล้ว

    Very good advice my friend. Thank you.

  • @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.

  • @pepeback
    @pepeback 5 ปีที่แล้ว +4

    Typo: Plane, not Plain. Good video :)

  • @jeffreysacco
    @jeffreysacco 5 ปีที่แล้ว +11

    Awesome tutorial. Plain should be spelt as plane.

    • @TheCodeholic
      @TheCodeholic  5 ปีที่แล้ว +2

      Ups.. Thanks for noticing...

  • @tambovskya
    @tambovskya 4 ปีที่แล้ว +1

    Nice...

  • @Raezon_
    @Raezon_ 4 ปีที่แล้ว

    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.

  • @wilwerrodriguez1787
    @wilwerrodriguez1787 4 ปีที่แล้ว +1

    perfect thanks

  • @SPOKOZE2
    @SPOKOZE2 4 ปีที่แล้ว +1

    15:07 why there is "Hello from class AHello from trait A" not "Hello from trait AHello from class A"?

    • @nemac23
      @nemac23 3 ปีที่แล้ว

      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.

  • @kesogonzaga2671
    @kesogonzaga2671 3 ปีที่แล้ว

    Thanks bro

  • @jihadabdulrazaq338
    @jihadabdulrazaq338 2 ปีที่แล้ว +1

    I have a question, interfaces also accepts multiple inheritance, so what's the difference between interfaces and traits?

    • @TheCodeholic
      @TheCodeholic  2 ปีที่แล้ว +4

      Interfaces only contain the method names and signature. But traits contain method implementations as well.

    • @adipurnomo5683
      @adipurnomo5683 ปีที่แล้ว

      Noted

  • @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.

  • @mohammadhosein77
    @mohammadhosein77 4 ปีที่แล้ว

    So traits in php are analogous to interfaces in java?

    • @TheCodeholic
      @TheCodeholic  4 ปีที่แล้ว +1

      No.
      There are interfaces in PHP also. I am not Java expert, but I think there is no analog of traits in Java.

    • @mohammadhosein77
      @mohammadhosein77 4 ปีที่แล้ว

      @@TheCodeholic I've just found this question solving the problem:
      stackoverflow.com/questions/9205083/traits-vs-interfaces
      Thanks for the reply.

  • @cristhianjhlcom
    @cristhianjhlcom 3 ปีที่แล้ว

    In simple words is like a reusable component but for functions? i'm right? nice series of videos btw

    • @TheCodeholic
      @TheCodeholic  3 ปีที่แล้ว +1

      For classes.
      Their purpose is to achieve multiple inheritance.

    • @cristhianjhlcom
      @cristhianjhlcom 3 ปีที่แล้ว

      @@TheCodeholic Thanks, master