19

error_reporting:控制你的php程序报错等级

 4 years ago
source link: https://blogread.cn/it/article/1199?f=hot1
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

error_reporting:控制你的php程序报错等级

浏览:2274次  出处信息

   一次偶然的机会,发现发一段程序感觉诡异,于是详细查了一把文档。

原程序如下:

class os_cart {

    public function pay() {

        //do something

os_cart::pay();

即然成员函数声明的不是static的,为什么可以使用静态模式来调用呢?这样

为什么不会报错呢?查了一下文档,原来和error_reporting函数相关。如果

error_reporting的设置包含了E_STRICT的话,那么程序会进行严格的检查,

对于非静态函数进行静态方式调用,就会报错。如果将E_STRICT错误过滤掉

的话,就不会报错了。

error_reporting的设置方式:

    1 在php.ini配置文件中进行配置,相关值如下列表:

    2 在程序中进行设置,在程序入口处使用error_reporting函数进行设置

如 error_reporting(E_ALL | E_STRICT);这里需要说明的是,E_ALL并

不包含E_STRICT。

觉得文章有用?立即:

和朋友一起 共学习 共进步!

建议继续学习:

  1. PHP error_reporting的使用    (阅读:1639)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK