PHP isset for an array element while variable is not an array
问题 $a = 'a'; echo isset($a['b']); This code returns 1. Why? 回答1: String characters can be referenced by their offset using syntax like $a[0] for the first character, e.g. $string = 'Hello'; echo $string[1]; // echoes 'e' so PHP is recognising that $a is a string; casting your 'b' to a numeric (which casts to a 0), and trying to test isset on $a[0], which is the first character a Though it should also throw an illegal offset 'b' warning if you have errors enabled EDIT $a = 'a'; echo isset($a['b']