Posted by petermichaux on 09/17/05 19:47
Hi,
I am curious about how php deals with the following situation where I
use an undefined index into an array. PHP seems to be behaving exactly
how I want it to but I want to make sure that it is not a fluke. It
seems like most programming languages would crash if you used an
undefined index. Why does PHP work the way it does?
My example is below
Thanks,
Peter
<?php
$array['foo']=3;
echo 'M'.$array['foo'].'M';
//How can I index into the array to an index that doesn't exist?
echo 'M'.$array['bar'].'M';
//output
//M3MMM
//note there is no space between the last two M's
//this is exactly the result I want but why does it work?
?>
[Back to original message]
|