简体   繁体   中英

Cannot remove E_STRICT errors in Php 5.4

I moved a server from Php 5.3 to Php 5.4

Several errors showed up which did not show using Php 5.3

I tried disabling E_STRICT errors by entering this in php.ini

error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT

It had no effect. The same errors kept being displayed.

I run grep -r "error_reporting" . at one website, to find if the script was setting it, but no. It was not found.

An example of an error: "illegal string offset" when checking for a key in an array.

I have many scripts on this server and it is not possible to check all the code for when an array string is used without first checking it with isset.

How can I disable those E_STRICT errors in Php 5.4 so I can keep running these older scripts without having to stick to Php 5.3 ?

  1. Illegal string offset is a warning , not an E_STRICT error. The code is plain wrong , not merely "strictly speaking sub-par". The reason you can't suppress the error is that it's a serious error which you are explicitly allowing.
  2. Illegal string offset means you're most likely treating a string like an array, eg:

     $foo = 'bar'; echo $foo['baz'];

    'baz' is an illegal string offset . A string offset is supposed to be a number. If you're using something other than a number, that a) doesn't make sense and b) is a sign that you probably expected $foo to be an array. So, again, plainly wrong code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM