In php version 5.6, use the substr
function to intercept strings. code show as below
substr("123456", 0, 2);
AppearUse of undefined constant 0 - assumed ' 0'
The online solution is to modify error_reporting
in php.ini to turn off notice
. But what is this essential question? ? If you don't close this notice
configuration, how to solve it? ?
Thanks for the invitation!
It’s not a function problem, but that you used the undefined constant 0. You can take a look at your code again. Is the 0 in your context a full-width space?
If I read it correctly, this
Use of undefined constant 0 - assumed ' 0'
.0 There is a space in front of it. If it is just a space (u20), there should be no error.
I guess you used full-width spaces, causing '0' to become a variable. But in PHP, variables need to be defined with $, so this '0' is programmed as a constant.
Translation: Undefined constant used.