[TYPO3-dev] Code beauteousness

Christian Welzel gawain at camlann.de
Wed Dec 2 23:32:43 CET 2009


Peter Russ wrote:

> Just wondering what the author of this poem is trying to say us:
> 
> $content = array('user' => array(), 'html' => array(), 'admin' =>
> array(), 'mail' => array());
> $content['mail'] = '';
> $content['user']['all'] = '';
> $content['html']['all'] = '';
> $content['admin']['all'] = '';

He is initializing array members to an empty value?
I cannot see, whats wrong with it.
Ok, this could all be in the first line, but thats personal style, isnt it?

> $content['mail'] = '';

This is probably a typo and the ['all'] is missing. 

I why all this?
Perhaps to avoid nasty php notice warnings in the log file when accessing
undefined array members:

> error_reporting(E_ALL);
> $content=array("foo" => array());
> if($content["foo"]["bar"]=="dummy");
>
> Notice: Undefined index:  bar in Command line code on line 3

The original code seems a bit stupid, but its not.


-- 
 MfG, Christian Welzel

  GPG-Key:     http://www.camlann.de/key.asc
  Fingerprint: 4F50 19BF 3346 36A6 CFA9 DBDC C268 6D24 70A1 AD15




More information about the TYPO3-dev mailing list