> > 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'?  If the
> former, then I would argue as to whether it is valid syntax,
> since depending
> on it would be dangerous.  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.


I believe it is the latter, i.e. designed to work that way. I read something
about it a few months ago but annoyingly can't find the reference. The
reasoning was to make it easier for developers to manage files that define
large arrays, such as config files. (You can add extra values to the end,
copy/paste lines etc without having to worry too much about the trailing
commas).

It may only be acceptable in newer versions of PHP though.

> >
> > NULL is a special type that means just that:
> > http://uk.php.net/manual/en/language.types.null.php
> >
> > Enclosing it in quotes will define it as a string, something entirely
> > different.
>
> I am aware of what a NULL is.  I suggested the quotes as a troubleshooting
> step, since code prior to the NULL was not being displayed.  A 'knee jerk'
> suggestion, I concede. (Feel free to substitite your own
> descriptive phrase
> for 'knee jerk' if you must) :-)

No need - I'm just as guilty as anyone for 'knee-jerk' posting :)

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

Reply via email to