Thinkphp报错,详细见问题补充。但是好像不影响使用

错误信息:[2048]DeclarationofIndexAction::show()shouldbecompatiblewiththatofAction::show()... 错误信息:[2048] Declaration of IndexAction::show() should be compatible with that of
Action::show() I:\PHPnow\htdocs\ThinkPHP\Home\Lib\Action\IndexAction.class.php 第
10 行.

代码段:
<?php
class IndexAction extends Action {
public function show(){
$m=M('User');//实例化 new model()
$arr=$m->select();
$this->assign("data",$arr);
$this->display();
}
}
展开
 我来答
songyipangbuo
推荐于2017-11-26 · TA获得超过744个赞
知道小有建树答主
回答量:190
采纳率:100%
帮助的人:251万
展开全部
代码段:
<?php
class IndexAction extends Action {
public function show(){
$m=M('User');//实例化 new model()
$arr=$m->select();
$this->assign("data",$arr);
$this->display();
}
}
如上面的代码:类Action中的show方法有参数,类IndexAction在继承Action后重写show方法时去除了参数,因此会产生一个类似下面E_STRICT级别的警告:
Strict standards: Declaration of ... should be compatible with that of ...
意思就是子类(IndexAction)重写的show方法与父类(Action)中的show方法不兼容,php方法重写要求是要参数个数、方法名称与父类要一致的,你要重写的话就要这样定义:
public function show($content,$charset='',$contentType='',$prefix=''){
//.....

}
不过不是错误,只是警告不影响运行。
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式