: 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.