作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的类构造函数中,我有以下内容:
set_error_handler(array(
$this,
'_custom_error_handler'
));
在同一个类中,我定义了以下方法:
protected function _custom_error_handler($error_number, $error_string, $error_file, $error_line)
当我的代码中出现错误时,我会收到以下警告:
Warning: Invalid callback ... _custom_error_handler, cannot access protected method
为什么这个类(或其子类?)不能访问这个 protected 方法? protected 方法不应该是可访问的吗???
最佳答案
protected 方法只能从类或子类内部访问。
在这种情况下,set_error_handler 正在调用一个方法,而 set_error_handler 在您的类之外。因此它必须是公开的。
关于PHP: set_error_handler 和 visibily,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44656352/
在我的类构造函数中,我有以下内容: set_error_handler(array( $this, '_custom_error_handler' )); 在同一个类中,我定义了以下方
我是一名优秀的程序员,十分优秀!