Because PHP’s grammatical requirements are not strict, strings can also be used as arrays, so there is a problem: when using non-numbers as keys to access the content in the string, some inconsistencies may occur, such as the following Code
1 $hello = "hello" ;
2 var_dump( $hello [ 'abc' ]);
3 var_dump( $hello [ '0' ]);
4 var_dump( $hello [ '1abc' ]);
5 var_dump($hello ['12abc']);
Result:
'h'
'h'
'e'
''
I won't say the output result , you can know by simply running it. I think the reason is caused by intval. Due to time constraints, I did not confirm the zend code, but the running result page of the following code illustrates some problems
1 var_dump( intval ( 'abc ' ));
2 var_dump( intval ( '0' ));
3 var_dump( intval ( '1abc' ));
4 var_dump( intval ( '12abc' ));
This stuff, yes This is a very lethal bug during code review or testing. If the return value of a function is not well designed, sometimes it returns an array and sometimes it returns a string. Before using it, you must first determine whether the return result is an array. Otherwise, this bug will be blamed