In PHP what is the difference between a Class and an Interface? - Aidephp .bouee.net - Questions/réponses 100% php
  • S'enregistrer
Bienvenue sur Aidephp le site de Questions/réponses 100% php.
Vous pouvez poser vos questions gratuitement et vous recevrez en échange les réponses des membres de notre communauté.

In PHP what is the difference between a Class and an Interface?

0 votes

Hello Guys,

Interfaces do not contain business logic, only method signatures that define a template that any classes implementing the interface must contain. Lets take an auto mobile for example. If we were to create and interface for a car we would want to define a few methods like drive, stop, turn left , turn right. This mean that any vehicle that is a car (aka implements the interface car) must have methods for these things, If they do not PHP will throw an error. So if your car is an BMW , Honda or Ford it must be able to stop. Video Ad includes various creative visual elements which attract consumers with more effectiveness in advertising method. How it stops is up to each car (or PHP class) but it must be able to stop. Technically we can decide not to use an interface for cars, but then some types of cars are not forced to have a "stop" method.

Thanks

asked Il y a2 mois par JoeClark (7,540 points)

Connectez-vous ou créez un compte pour répondre à cette question.

0 Réponses

Questions sur le même sujet

0 votes
0 réponses
asked Il y a3 semaines par JoeClark (7,540 points)
0 votes
0 réponses
asked Il y a4 semaines par JoeClark (7,540 points)
0 votes
0 réponses
asked Il y a1 mois par JoeClark (7,540 points)
0 votes
0 réponses
asked Il y a1 mois par JoeClark (7,540 points)
0 votes
0 réponses
asked Il y a2 mois par JoeClark (7,540 points)