Re: No notices for undefined index

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>> print $a[0];   // prints 5
>> print $a[100]; // Notice: Uninitialized string offset:  100
Yup, this should happen when 5 is treated as an array of characters.
In other words as a string.
$a = '5';
echo $a[0];
echo $a[100];
gives you the expected result

regarding the original question, i think that the interpreter is
prefilling the variable with null

$a = 5;
var_dump(isset($a[0]));
var_dump($a[0]);

since $a[0] is already assigned (to null) the interpreter is not
throwing a notice

$b = null;
var_dump(isset($b));
var_dump($b);

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux