d-_-b d-_-b - 1 year ago 63
PHP Question

PHP: white space between function name and parenthesis

I'm wondering if this is legal:



Or perhaps this:

$items = array
"Details" => array('controller' => 'event', 'action' => 'readall', 'tab' => 'details'),
"Calendar" => array('controller' => 'event', 'action' => 'readall', 'tab' => 'calendar')

Or will some interpreters choke?

I know the popular mixed style of classes and functions have the opening curly brace on a new line and control structures, such as "if", on the same line. However, I like all one or the other. Newline or no newline. It would be nice to extend the concept to function calls and their parenthesis as well. This is the reason for my question.

Answer Source

That is very legal. And there aren't many interpreters after all. :) I put parentheses on the next line too if I got a large amount of parameters or a large array declaration.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download