"elseif" vs "else if"

Events happening in the community are now at Drupal community events on www.drupal.org.
stella's picture

In the latest code review done by chx and Morbus at http://www.drupaltoughlove.com, one of the items commented on was the usage of "else if" instead of "elseif". There's nothing in the Coding Standards doc that specifically states that one should be used over the other, however it is "implied" from the first example on indentation that "elseif" should be used. Can the Coding Standards doc be updated so that it states one way or the other? Personally I don't mind which, but I would prefer if there was consistency. Core itself has a mixture, but with a higher number of "elseif".

An issue on this has already been raised at http://drupal.org/node/282405

Cheers,
Stella

Comments

:)

sun's picture

I'm glad I'm not the only one who was surprised of this statement.

Personally, I prefer else if, because I find it easier to read, but I also think it doesn't matter at all.

Daniel F. Kudwien
unleashed mind

Daniel F. Kudwien
netzstrategen

Some lenguajes don't support elseif

markus_petrux's picture

So I'm in favor of else if for that reason. :-)

"Some languages don't

morbus iff's picture

"Some languages don't support elseif?" I'm not entirely sure what that means. The only language we need to worry about supporting is PHP. The PHP documentation defaults to using elseif. PEAR defaults to using elseif. There are downsides for using "else if" (such as the colon variant, described in the linked issue). "elseif" is one word, compared to "else if", which would make it the only two word syntax in all of Drupal (and in all of PHP).

markus_petrux's picture

It just means I believe it's easier to remind one form than two depending on the languaje being used. With Drupal it's easy to write PHP and Javascript almost at the same time, for instance. But anyway, there are other differences to take into account (ie. boolean constants, null, etc) so it is not that important another difference after all.

Coding standards

Group organizers

Group categories

Status

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds:

Hot content this week