php版本5.4.12
PHP Strict Standards: Declaration of db_attach::needBy() should be compatible with spModel::needBy($id, $value) in C:\php\web\db\db_attach.php on line 25重写的时候参数不一致,看了网上的方法
1.给重写的函数参数初始化
2.设置error_reporting为error_reporting(E_ALL & ~(E_STRICT | E_NOTICE))(我是在php.ini添加的)总是无法屏蔽这个错误。请问有什么办法吗?谢谢php
PHP Strict Standards: Declaration of db_attach::needBy() should be compatible with spModel::needBy($id, $value) in C:\php\web\db\db_attach.php on line 25重写的时候参数不一致,看了网上的方法
1.给重写的函数参数初始化
2.设置error_reporting为error_reporting(E_ALL & ~(E_STRICT | E_NOTICE))(我是在php.ini添加的)总是无法屏蔽这个错误。请问有什么办法吗?谢谢php
解决方案 »
- 替换preg_replace.怎么老是【吃掉】前面的一个字符...
- list和each的问题
- log4php性能问题,请高手帮忙
- 不用form怎么post数据
- 请教一个网络抓包软件。。
- 初学者的一个类的问题,请高手指点!!!
- 注册用户失败: You have an error in your SQL syntax near 'user(name,password, tel, regtime) values('zhangmeng','8cb3b0caf964430fe
- phpmyadmin导出的50m的文件怎么恢复?
- 关于注册中的问题 ,急!!!!
- php 数组unset排序和json的问题
- 修改xml文件值的问题
- 高手都不告诉小弟是吧
public function needBy($field, $value)
{
return $this->find(array($field=>$value));
}
}class dbconect extends access
{
function needBy($id)
{
return $this->find(array('id'=>$id),'','uid,path');
}
}谢谢,帮忙看看,还需要什么随时提供
测试了一下class c { function test( $a ) { return 1; } }
class cc extends c { function test() { return null; } }
$cc = new cc(); Strict Standards: Declaration of cc::test() should be compatible with c::test($a) in ...这很简单,重写方法的函数签名本应该就和基类函数是一致的,这也是符合自然规律的,因为override本来就是覆盖的意思嘛,既然覆盖了,那么就应该和原函数一致,不然怎么能“盖”的住呢
dbconect 继承于 access
dbconect::needBy($id) 只有一个参数,所以出错。原因上面已说
只需
dbconect::needBy($id, $null=null) 加一个可缺省的参数
就可以了
---------------
<?php
// this code does trigger a strict message
error_reporting( E_ALL | E_STRICT );class cc extends c {
function test() { return null; }
}class c {
function test( $a ) { return 1; }
}
$cc = new cc();
?><?php
// this code does NOT trigger a strict message
error_reporting( E_ALL | E_STRICT );class c {
function test( $a ) { return 1; }
}class cc extends c {
function test() { return null; }
}$cc = new cc();
?>Expected result:
----------------
None of the code blocks should trigger an error (my personal preference) or both code blocks must trigger a notice.Actual result:
--------------
First block triggers:
Strict standards: Declaration of cc::test() should be compatible with that of c::test() in strict_test.php on line 4Second does nothing at all.
php 用的人太多了,所以开发者们有意的制造些障碍
到 php5.5 就可能象 java 一样严厉了
于是就成了解释执行的 java —— 永远跟在 java 后面吃屎