Today, the program suddenly appears to have this error
Fatal error:access level to XXX must is protected (as in class XXX) or weaker in xxx.php
The reason is that the same method name as the parent class is defined in the subclass
Sub class:
Private Function Return_json ($message, $result = ' true ') {
$data = Array ();
$data [' result '] = $result;
$data [' message '] = $message;
Self::echo_json ($data);
}
Private Function Echo_json ($data) {
if (Strtoupper (CHARSET) = = ' GBK ') {
$data = Language::getutf8 ($data);//Site GBK when encoding is used, convert to UTF-8 to prevent JSON from outputting kanji problems
}
echo Json_encode ($data);
}
Parent class:
/**
* Return to JSON state
*/
protected function Return_json ($message, $result = ' true ') {
$data = Array ();
$data [' result '] = $result;
$data [' message '] = $message;
Self::echo_json ($data);
}
protected function Echo_json ($data) {
if (Strtoupper (CHARSET) = = ' GBK ') {
$data = Language::getutf8 ($data);//Site GBK when encoding is used, convert to UTF-8 to prevent JSON from outputting kanji problems
}
echo Json_encode ($data);d ie;
}
Solutions
The private in the handle class is changed to protected, or avoid the duplicate of the method. In this example, it is obvious that the same method is used to define the duplicate, and the subclass deletes the two methods.