PHP:函数名称和括号之间的空格
我想知道这是否合法:
<?php
is_null
(
$var
);
或者也许是这样:
<?php
$items = array
(
"Details" => array('controller' => 'event', 'action' => 'readall', 'tab' => 'details'),
"Calendar" => array('controller' => 'event', 'action' => 'readall', 'tab' => 'calendar')
);
或者一些口译员会窒息吗?
我知道流行的类和函数的混合风格在新行上有左大括号,在同一行上有控制结构,例如“if”。然而,我喜欢其中之一。换行或不换行。如果能将这个概念扩展到函数调用及其括号,那就太好了。这就是我提出这个问题的原因。
I'm wondering if this is legal:
<?php
is_null
(
$var
);
Or perhaps this:
<?php
$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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是非常合法的。而且口译员毕竟不多。 :) 如果我有大量参数或大数组声明,我也会在下一行加上括号。
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.
这是合法的。解释器应该忽略它发现的任何空白。
It's legal. the interpreter should just ignore any white space it finds.
空白并不重要。我唯一一次知道解释器关心空格是在退出 HEREDOC 语法时。除此之外,您可以根据需要添加任意数量的空格或换行符。
Whitespace doesn't matter. The only time I'm aware that the interpreter cares about whitespace is when exiting HEREDOC syntax. Other than that, you can have as many spaces or newlines as you want.