関数コール

関数は、関数名・開きカッコおよび最初のパラメータそれぞれの間には空白を置かず、 カンマとパラメータ間には空白を置き、最後のパラメータと閉カッコ およびセミコロンの間には空白を置かずにコールします。 例を示します。

<?php
$var 
foo($bar$baz$quux);
?>

上記のように、関数の返り値を変数に代入する際に使用する等号の左右には、 空白を1つづつ置きます。関連する一連の代入文については、 可読性を向上させるために空白を複数置いても良いでしょう。

<?php
$short         
foo($bar);
$long_variable foo($baz);
?>
制御構造 (Previous) クラス定義 (Next)
Last updated: Fri, 01 Aug 2014 — Download Documentation
Do you think that something on this page is wrong? Please file a bug report or add a note.
View this page in:

User Notes:

Note by: masiena@hotmail.com
"In a well written code you shouldn't use find/replace. Especially a mindless find/replace. If so take your time. "

Sure?

If you ALREADY have bad code, you will do find/replace. If you refactor code, you will do find/replace. If you don't like your predecessor's coding style in the project at hand, you will do find/replace.

In all that cases (and other, I suppose), extra spaces just get in the way. By the way, find/replace that uses REs get complicated by extra spaces.

Just some thoughts of someone that has been in the battle field. For the last 25 years.

Cheers.


Note by: user@example.com
In a well written code you shouldn't use find/replace. Especially a mindless find/replace. If so take your time.
Note by: aheinz@lulu.com
Adding spaces for horizonal justification improves readability until you do a search/replace on a variable name. This practice should be discouraged.