PHP Interface - What is PHP Interface and How to Use It

Sdílet
Vložit
  • čas přidán 4. 08. 2024
  • In this video I explain what PHP interface is and how to use it.
    Upgrade your Clever Techie learning experience:
    / clevertechie
    Download this video's files here:
    / php-interface-is-37524626
    ``````````````````````````````````````````````````````````````````````````````````````````````
    ( Website ) clevertechie.com - PHP, JavaScript, Wordpress, CSS, and HTML tutorials in video and text format with cool looking graphics and diagrams.
    ( CZcams Channel ) / clevertechietube
    ( Facebook ) / clevertechie
    ( Twitter ) / theclevertechie
  • Jak na to + styl

Komentáře • 28

  • @oyinbrakemimichaelmenebray5966

    Very straightforward. Simple to understand

  • @eloquent2200
    @eloquent2200 Před 2 lety +1

    Thank you for good explanation!

  • @easywiesi2055
    @easywiesi2055 Před 10 měsíci

    thanks! finally i got it 👍

  • @saulespukje8
    @saulespukje8 Před 3 lety

    nice, thanks!

  • @dibbyo456
    @dibbyo456 Před 3 lety

    Perfect.

  • @keegers1
    @keegers1 Před 4 lety +7

    I guess I don't understand. Why write the interface if to still need to call the class/functions of the other class? Even the last part, you still copied and pasted the MySQL class to the new Oracle one.

    • @clevertechie
      @clevertechie  Před 4 lety +3

      Because the code of the function's implementation in the MySQL and Oracle classes can be different, this is the key thing to understand.

    • @CaptainBradleySmith
      @CaptainBradleySmith Před 3 lety +7

      @@clevertechie why code cant be different with same names of functions without that additional interface part?

    • @jareklotz
      @jareklotz Před 2 lety +2

      Answer : you can pass to function as a parametr class object and define in parameter, type of interface that object implements. Then, this function knows that this object has all necessary functions, so no error will occur. Example:
      myFunc(InterfaceName $object).

  • @Ruban_Sn
    @Ruban_Sn Před 3 lety +1

    2:41 aren't those supposed to called as "function declarations!?

  • @ArnVenture12
    @ArnVenture12 Před 4 lety

    Wow. Been a while???

  • @ahmedsunil3235
    @ahmedsunil3235 Před 4 lety

    What is your vscode theme setting including font?

    • @clevertechie
      @clevertechie  Před 4 lety +3

      Material Theme Ocean, Font: Consolas, 18

  • @ripplesr5655
    @ripplesr5655 Před rokem

    I don't seem to grasp the concept of, why would you use Interface if we are using the same name methods inside every classes anyway.

    • @ripplesr5655
      @ripplesr5655 Před rokem

      Ok, got it. Basically this helpls you in the development phase by forcing you to adhere to a set of rules that implements the interface. Anyone, coming from TypeScript should not have any issue understanding this.

  • @DoctorMGL
    @DoctorMGL Před rokem +2

    still don't get it ,
    because thats just adding more size to your code while you can define the function + it functionality directly without the interface,
    i thought its like in C# where you can update something live in the UI using interface , or at least sharing the same triggered information across the app as in C++ and UE blueprint
    but in php it turn to be a joke , it just define a function name for you thats it . 0 real benefits
    its like Filling a circle with the same color twice, while the first " Fill " was enough

    • @ripplesr5655
      @ripplesr5655 Před rokem

      Exactly that is what I am thinking. What is the point tho?

    • @ripplesr5655
      @ripplesr5655 Před rokem

      Ok, got it. Basically this helpls you in the development phase by forcing you to adhere to a set of rules that implements the interface. Anyone, coming from TypeScript should not have any issue understanding this.

    • @returnMarcco
      @returnMarcco Před rokem +2

      For example, say you have 10 classes implementing the same interface, and the interface has one method called echo_text(). You could loop over the 10 instances of those classes and call the echo_text() method on each of the 10 objects and be sure that method exists, without even knowing the implementation of the method.

  • @ellmatic
    @ellmatic Před 5 měsíci

    weird, i've never seen anyone use spaces in their class filenames

  • @NoAdsMurad-t3t
    @NoAdsMurad-t3t Před 3 dny

    When you are creating an object to the actual classes, then why you need an Interface? I mean the interface looks useless here.

  • @anupkaushik9370
    @anupkaushik9370 Před rokem

    You mean Abstraction and Interfaces are same thing

    • @returnMarcco
      @returnMarcco Před rokem

      Polymorphism. Abstraction has to do with abstract classes

  • @mrmbeautiquethebrand
    @mrmbeautiquethebrand Před 2 lety

    I don't understand. Why u are using interfaces.. Thoes work done by change class if your other class has same method you can change it your implementation class

    • @thedude9014
      @thedude9014 Před 2 lety +10

      I think Interfaces are used to make sure that all function that are needed are present in the class . what he missed was that if you forget to implement those function you get an error. An interface is a sort of contract and it's more about organizing code that provide a funtionality

    • @witcherle9944
      @witcherle9944 Před rokem

      @@thedude9014 your comment should be pinned

    • @Rex-lp1dl
      @Rex-lp1dl Před 5 měsíci

      @@thedude9014 You nailed it. That's more precise