php版本5.6中使用substr
函数 进行字符串截取。代码如下
substr("123456", 0, 2);
出现Use of undefined constant 0 - assumed ' 0'
网上解决方案是修改 php.ini 中error_reporting
将notice
关闭。但是这个本质问题是什么?? 如果不关闭这个notice
配置,怎么解决??
typecho2017-06-10 09:49:52
如果我没有看错的话,这个 Use of undefined constant 0 - assumed ' 0'
.
0 前面有一个空格,如果单纯是空格(u20)的话,应该没有错误。
我猜测你使用了全角空格,导致 ' 0' 变当作了变量。但是在 PHP 中,变量需要加 $ 来定义,所以这个 ' 0' 就编程了常量。
Use of undefined constant 0
翻译:使用了未定义的常量。