复制代码 代码如下:
interface js{
function ys($a,$b);
}
class Af implements js{
function ys($a,$b){
return "加法运算......结果为:".($a+$b);
}
}
class Jf implements js{
function ys($a,$b){
return "减法运算......结果为:".($a-$b);
}
}
class AAf implements js{
function ys($a,$b){
return "乘法运算......结果为:".($a*$b);
}
}
class JJf implements js{
function ys($a,$b){
return "除法运算......结果为:".($a/$b);
}
}
class Modf implements js{
function ys($a,$b){
return "取模运算......结果为:".($a % $b);
}
}
class China implements js{
public $varl=null;//这里直接:public $varl = new nothingx(); 会出错。
function __construct(){
$this->varl = new nothingx();
}
function ys($a,$b){
return $this->varl->say();
}
}
/*也可以用继承的方式实现哟:
class China extends nothingx implements js{
function ys($a,$b){
return parent::say();
}
}
*/
class nothingx{
function say(){
return "我什么运算都不做...只是为了实现‘耦合设计模式'...我是出来打酱油的......";
}
}
class test{
private $one;
private $two;
public function __construct($x,$y){
$this->one=$x;
$this->two=$y;
echo "面向对象程序设计——接口
Class test初始化:
属性\$one=".$this->one." 属性\$two=".$this->two."
";
}
function display(js $a){
return "用PHP接口技术实现的运算——开始运算啦:
".$a->ys($this->one,$this->two)."
";
}
}
$t=new test(103,2);
$t1=new jf;
$t2=new China;
echo $t->display($t1);
echo $t->display($t2);
?>

Heiße KI -Werkzeuge

Undresser.AI Undress
KI-gestützte App zum Erstellen realistischer Aktfotos

AI Clothes Remover
Online-KI-Tool zum Entfernen von Kleidung aus Fotos.

Undress AI Tool
Ausziehbilder kostenlos

Clothoff.io
KI-Kleiderentferner

AI Hentai Generator
Erstellen Sie kostenlos Ai Hentai.

Heißer Artikel

Heiße Werkzeuge

VSCode Windows 64-Bit-Download
Ein kostenloser und leistungsstarker IDE-Editor von Microsoft

MantisBT
Mantis ist ein einfach zu implementierendes webbasiertes Tool zur Fehlerverfolgung, das die Fehlerverfolgung von Produkten unterstützen soll. Es erfordert PHP, MySQL und einen Webserver. Schauen Sie sich unsere Demo- und Hosting-Services an.

ZendStudio 13.5.1 Mac
Leistungsstarke integrierte PHP-Entwicklungsumgebung

Dreamweaver Mac
Visuelle Webentwicklungstools

MinGW – Minimalistisches GNU für Windows
Dieses Projekt wird derzeit auf osdn.net/projects/mingw migriert. Sie können uns dort weiterhin folgen. MinGW: Eine native Windows-Portierung der GNU Compiler Collection (GCC), frei verteilbare Importbibliotheken und Header-Dateien zum Erstellen nativer Windows-Anwendungen, einschließlich Erweiterungen der MSVC-Laufzeit zur Unterstützung der C99-Funktionalität. Die gesamte MinGW-Software kann auf 64-Bit-Windows-Plattformen ausgeführt werden.