PHP无法从界面扩展? [英] PHP can't extend from interface?
本文介绍了PHP无法从界面扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在下面的单个php文件中写道。
I write below in a single php file.
<?php
interface people
{
public function take($s);
}
class engineer extends people
{
public function take($s){
echo $s;
}
}
?>
人是一个界面,工程师扩展人。
但是当我运行此代码时,错误:
The people is an interface, the engineer extends people. But when I run this code, the error:
Fatal error: Class engineer cannot extend from interface people in E:\php5\Mywwwroot\b.php on line 12
发生了什么事?我的PHP版本是5.4。
What's happened? My PHP version is 5.4.
推荐答案
你实现接口和扩展课程:
<?php
interface people
{
public function take($s);
}
class engineer implements people
{
public function take($s){
echo $s;
}
}
?>
这篇关于PHP无法从界面扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文