Home  >  Article  >  Backend Development  >  php5.3.1支持多承袭

php5.3.1支持多承袭

WBOY
WBOYOriginal
2016-06-13 12:48:17714browse

php5.3.1支持多继承?
以前php是不支持多继承的,现在可以支持多继承了
在学习的过程中无意发现了以下的现象
class A{
function X(){
echo 'y' ;
}
function test(){
echo "df" ;
}
}
class B extends A{

function Y(){
echo parent::X() ;
}
}
class C extends B{
function Z(){
echo parent::Y() ;
}
}
$c = new C() ;
$c->X() ;
$c->test() ;
 ?>
输出结果:ydf


------解决方案--------------------
PHP不支持多继承,支持单继承,如果一定要实现多继承,教程里有使用接口实现多继承的。
Statement:
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