On 18/05/07, Jim Moseby <[EMAIL PROTECTED]> wrote:
>
> The extra comma at the end of the array definition is still
> valid syntax in
> PHP. Try for yourself:
>
>  php -r '$a = array("a" => "foo", "b" => "bar",); print_r($a);'

Interesting.  Do you mean 'Valid Syntax' in that it 'works without error',
or 'Valid Syntax' in that 'it was designed to work that way'?

It was designed to work that way (see the 'possible_comma' rule in
zend_language_parser.y)

If the latter, then I have learned something new,
and I'd like to know more about why it is designed to work that way, and how
I could use it to my advantage.

Probably because

 1. People often remove or comment out elements from lists and forget
to remove the
 comma from the new last entry eg:

 $config = array(
        foo => bar,
 //     baz => wibble
        );

 2. Perl already made the final comma optional for similar reasons.

-robin

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

Reply via email to