This article is a detailed analysis and introduction to the meaning of interface in phpInterface. Friends who need it can refer to it
Maybe everyone knows this, but as someone who doesn’t understand, I I guessed the meaning of this interface. It is to call the content that exists in the interface in the implementation class in the method that will be called later. It’s so convoluted. I’ll write an example for future reference.
pay.php
The code is as follows:
interface Ipay { function withmoney(); //function withinternet(); } class Dmeng implements Ipay { function withmoney() { echo "花人民币买东西"; } function withinternet() { return "用网银支付"; } }
usei.php
The code is as follows:
include_once 'pay.php'; class main { function run($vc) { $this->vc = $vc; $this->vc->withinternet(); echo "yunxing"; } } $com= new main(); $com->run(new Dmeng);
As above, we will Comment out of this method, and it will be useless when you call it again
The above is the detailed content of The meaning of interface in php interface. For more information, please follow other related articles on the PHP Chinese website!