Questions about inheritance errors: php 5.4.12PHP & nbsp; Strict & nbsp; Standards: & nbsp; Declaration & nbsp; of & nbsp; db_attach: needBy () & nbsp; shocould & nbsp; be & help: Questions about inheritance errors
Php version 5.4.12
PHP Strict Standards: Declaration of db_attach: needBy () shocould be compatible with spModel: needBy ($ id, $ value) in C: \ php \ web \ db \ db_attach.php on line 25
The parameters are inconsistent during rewriting. I checked the online method.
1. initialize the rewritten function parameters.
2. set error_reporting to error_reporting (E_ALL &~ (E_STRICT | E_NOTICE) (I added it in php. ini)
This error cannot be blocked. Is there any way? Thank you, php.
------ Solution --------------------
Wait!
Tested
class c { function test( $a ) { return 1; } }
class cc extends c { function test() { return null; } }
$cc = new cc(); Strict Standards: Declaration of cc: test () shocould be compatible with c: test ($ a) in...
This is very simple. the signature of the function of the rewrite method should be consistent with that of the basic class function. this is also in line with the natural law, because override originally meant to be overwritten, so it should be consistent with the original function. Otherwise, how can it be "covered "?
------ Solution --------------------
Haha, posting is faster than writing
Access: needBy ($ field, $ value) has two parameters
Dbconect inherits from access
Dbconect: needBy ($ id) has only one parameter, so an error occurs. The reason is described above
Only
Dbconect: needBy ($ id, $ null = null) add a default parameter
You can.