In the first case, $a=5 creates a multi-typed variable. The interpreter makes its best guess how the next two expressions should be interpreted. In both cases, they look a lot like an index into a character array (string), and 'test' evaluates numerically to zero. Both are valid offsets for a string, so no messages are generated. In the second case, $a is explicitly declared as an array. This give the interpreter a lot more detail to work from. The two expressions are now an index and a key for the array. But both of them evaluate to offsets that have not been assigned, which raises a flag and creates the warnings. Such are the joys of loosely typed languages. Bob McConnell -----Original Message----- From: Andre Polykanine [mailto:andre@xxxxxxxx] Sent: Thursday, April 08, 2010 1:45 PM To: Shawn McKenzie Cc: php-general@xxxxxxxxxxxxx Subject: Re: No notices for undefined index Hello Shawn, Hm... isn't it expected behavior? Since you haven't defined a $a['test'] item, PHP throws a notice... or I'm wrong? -- With best regards from Ukraine, Andre Skype: Francophile; Wlm&MSN: arthaelon @ yandex.ru; Jabber: arthaelon @ jabber.org Yahoo! messenger: andre.polykanine; ICQ: 191749952 Twitter: m_elensule ----- Original message ----- From: Shawn McKenzie <nospam@xxxxxxxxxxxxx> To: php-general@xxxxxxxxxxxxx <php-general@xxxxxxxxxxxxx> Date: Thursday, April 8, 2010, 8:36:21 PM Subject: No notices for undefined index So the first two print statements generate NO notices, while the second obviously generates: Notice: Undefined offset: 1 in /home/shawn/www/test.php on line 11 Notice: Undefined index: test in /home/shawn/www/test.php on line 12 This sucks. A bug??? error_reporting(E_ALL); ini_set('display_errors', '1'); $a = 5; print $a[1]; print $a['test']; $a = array(); print $a[1]; print $a['test']; -- Thanks! -Shawn http://www.spidean.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php