Nitin Reddy wrote:
> I've noticed that when creating Mantis plugins, leaving out the closing
> PHP tag (the "?>") is encouraged. I'm not really sure why, but the
> Joomla community recommends it too. Why is this practice followed? I'm
> guessing this might be to ensure no spaces are sent to the output stream
> before sending out headers, seeing how many PHP developers accidentally
> add in a blank line or space following the closing PHP tag.
That is more-or-less the correct reasoning.
> Also, I've noticed that the examples in the Mantis plugin overview
> examples declare arrays with a comma following the last element, like
> this: array(1, 2, 3, )
> Is there any reason why we add in the extra comma?
When creating multi-line array definitions, adding a comma after every element,
including the last one, allows for patch diffing to look nicer. For example, if
you leave out the last comma, and then want to add another item, the patch
removes a line, and adds two. However, with the last comma, the same patch only
adds a single line, which more closely represents the change made to the file.
Basically, it's an aesthetic style designed to make the commit logs shorter and
easier to understand.