Re: No notices for undefined index

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

 



On Fri, 2010-04-09 at 07:52 +0530, kranthi wrote:

> >> 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);
> 


If $a is treated as an array of characters, then $a[0] is always the
first character, not null.

Thanks,
Ash
http://www.ashleysheridan.co.uk



[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