PHP 5.4: disable warning “Creating default object from empty value”

前端 未结 4 1920
萌比男神i
萌比男神i 2020-12-10 05:16

I want to migrate code from PHP 5.2 to 5.4. This worked fine so far except that all the code I use makes extensive use of just using an object with a member without any init

4条回答
  •  北海茫月
    2020-12-10 05:49

    I had the same problem i handle it like bellow in production environment

        \error_reporting(\E_ERROR);
    

    I have to say that my application doesn't need/generate errors, it's on a very controlled environment so doing this wouldn't hurt much, but if your application is an error prone one you should have you own error handler and with a proper regex and preg_match ignore the “Creating default object from empty value” warning and log/prompt others at your discretion.

提交回复
热议问题