Questions about inheritance exceptions

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.