<?php
// interface 多继承
class Base{
public function sayHello(){
echo "hello";
}
}
trait SayWorld{
public function sayHello(){
parent::sayHello();
echo "world";
}
}
trait SayWorld2{
public function sayHello2(){
echo "PHP";
}
}
class MyHelloWorld extends Base{
use SayWorld,SayWorld2;
}
$s = new MyHelloWorld();
$s->sayHello();
$s->sayHello2();
PHP多继承
最新推荐文章于 2023-02-10 00:18:21 发布