Home > Backend Development > PHP Tutorial > The meaning of interface in php interface

The meaning of interface in php interface

怪我咯
Release: 2023-03-12 18:32:01
Original
3310 people have browsed it

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 "用网银支付";
 }
}
Copy after login

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);
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template