|   | php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login | 
| 
  [2001-06-02 22:23 UTC] gabriel dot barros at folha dot com dot br
 $t1 = array("nome"=>"gabriel", "idade"=>"19");
$t2 = "asd";
$t3 = NULL ;
echo "<br><br>\n\n1: " . isset($t1{"nome"});
echo "<br><br>\n\n2: " . isset($t2{"nome"}); # there's NO "nome" defined! shouldn't it return FALSE? why does it retur TRUE ???
echo "<br><br>\n\n3: " . isset($t3{"nome"});
echo "<br><br>\n\n4: " . isset($t4{"nome"});
echo "<br><br>";
echo "<br><br>\n\n1: " . empty($t1{"nome"});
echo "<br><br>\n\n2: " . empty($t2{"nome"}); # It doesn't even exist! how can it be not even empty ???
echo "<br><br>\n\n3: " . empty($t3{"nome"});
echo "<br><br>\n\n4: " . empty($t4{"nome"});
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits             | |||||||||||||||||||||||||||
|  Copyright © 2001-2025 The PHP Group All rights reserved. | Last updated: Fri Oct 31 20:00:01 2025 UTC | 
isset($t2{"nome"}) is evaluating to true because you're using a string as an array, which is a perfectly legal thing to do. In this case, "nome" is being evaluated to zero (As all strings evaluate to) and the isset is seeing that $t2{0} exists, it's 'a' in the string 'asd'. Side note, it's not recommended to use curly braces when accessing array elements. Use square brackets instead, $array['key'] instead of $array{'key'}