문제

An invalid PHP string index usage that has been in place since 2008 today started causing an error. Debugging the reason for the invalid string index is not part of my question. The question is why does this only appear on certain servers?

Here is an example of the code:

$str = '0:828:555555';
$y = $str['id'];

The presence of the ['id'] appears to be the problem that causes the crash on one server but not on any of our production servers. So the invalid coding has been escaping for all these years.

The PHP levels and error_reporting levels unfortunately are not the same. The one that lets the error pass is 5.3.8. The one that has the error is 5.4.24. In addition, the 5.4.24 has E_STRICT but all the other settings are the same.

So I turned E_STRICT off and the error still happens.

The simplistic answer is "the PHP levels are not the same." But the error has in place for a long time, and so has the difference in PHP levels.

Any ideas on the cause of the server-dependent crash?

도움이 되었습니까?

해결책

From the manual:

"As of PHP 5.4 string offsets have to either be integers or integer-like strings, otherwise a warning will be thrown. Previously an offset like "foo" was silently cast to 0."

http://www.php.net/manual/en/language.types.string.php

Probably PHP was recently updated to 5.4 on some of your servers, or you only recently noticed this error.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top