Copy code The code is as follows:
interface js{
function ys($a,$b);
}
class Af implements js{
function ys($a,$b) {
return "Addition operation...the result is:".($a+$b);
}
}
class Jf implements js{
function ys($a,$b){
return "Subtraction operation ...The result is: ".($a-$b);
}
}
class AAf implements js{
function ys($a,$b){
return "Multiplication operation.... .The result is: ".($a*$b);
}
}
class JJf implements js{
function ys($a,$b){
return "The division operation...the result is:" .($a/$b);
}
}
class Modf implements js{
function ys($a,$b){
return "Modulo operation... the result is:".($a % $b);
}
}
class China implements js{
public $varl=null;//Directly here: public $varl = new nothingx(); will make an error.
function __construct(){
$this->varl = new nothingx();
}
function ys($a,$b){
return $this->varl->say();
}
}
/* can also be implemented by inheritance:
class China extends nothingx implements js{
function ys($a,$b){
return parent::say();
}
}
*/
class nothingx{
function say(){
return "I don't do any calculations...just to realize'Coupled design pattern' ...I'm here to make soy sauce...";
}
}
class test{
private $one;
private $two;
public function __construct($x,$y){
$this ->
$this->two=$y;
echo "Object-oriented programming - interface
The above introduces the simple examples of JavaScript design patterns, PHP interface-oriented programming, coupled design patterns, including the content of JavaScript design patterns. I hope it will be helpful to friends who are interested in PHP tutorials.