PHP object-oriented method rewriting

Source: Internet
Author: User
: This article mainly introduces PHP object-oriented method rewriting. if you are interested in PHP tutorials, refer to it. The wind is coming. fox

Method rewriting is required because sub-tables are used.

Error:

Declaration of... shocould be compatible .....

Use the following method to solve the problem:

Class Model {/** set the table sharding name * @ param int $ tableNum UID or table serial number * @ param int $ num digits * @ return $ this */public function tableSplit ($ tableNum = 0, $ num = 2) {$ this-> table ($ this-> getTableNameSplit ($ tableNum, $ num); return $ this ;}} class StockFlowModel extends Model {/** set the table sharding name * @ param int $ tableNum UID or table serial number * @ param int $ num * @ return $ this */public function tableSplit ($ tableNum = 0, $ num = 4) {if (empty ($ tableNum) {$ tableNum = date_time_format (DATE_TIME, 'ym');} parent: tableSplit ($ tableNum, $ num ); return $ this ;}}

Note:

During method override, the parameter name must be consistent with that of the parent class method, and the attribute overwrite must also be consistent.

When calling the parent class method, use parent: Method to call

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

The above introduces the PHP object-oriented method rewriting, including the content, hope to be helpful to friends who are interested in PHP tutorials.

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.