[TYPO3-50-general] TypoScript syntax: Array indexes

Robert Lemke robert at typo3.org
Thu Jul 19 14:55:16 CEST 2007

Hi Elmar,

Am 19.07.2007 um 14:31 schrieb Elmar Hinz:

> my personal feeling is, that one reason to invent TS was, to make  
> writing
> PHP as easy as writig JavaSript:
> one.two.three instead of $one['two']['three'] or $one->two->three.
> So we should ask, if it is a good idea to mix PHP elements into a  
> scripting
> language, that is rather JS orientated originally. Shouldn't we  
> search in
> the field of JS for syntax solutions first?


In JavaScript, arrays are a special thing - because they are just  
(Array-) objects.
You create properties by assigning a value to them and you can access  
properties like an associative array (in fact there isn't really  
something like an
associative array in JavaScript - you use objects and properties).

    one["two"]["three"] = "stuff"

is valid JS, and the same as

    one.two.three = "stuff"

However, it is only _almost_ the same! If you write

    two = "four";
    one.two.three = "stuff"

it would in reality be

    one["four"]["three"] = "stuff"

Next thing is that we probably don't want that you can create new  
properties by
just assigning a value - because that is almost never what the  
developer intended,
but more a typo which should throw an error message to help debugging.


More information about the TYPO3-project-5_0-general mailing list