SomeMethod (LongExpression1, LongExpression2, LongExpression3,
LongExpression4, LONGEXPRESSION5);
$var = SomeMethod1 (LongExpression1,
SOMEMETHOD2 (LongExpression2,
LongExpression3));
Here are two examples of broken arithmetic expressions. The former is better because the disconnect is outside the bracket expression, which is a higher level disconnect.
$longName 1 = $longName 2 * ($longName 3 + $longName 4-$longName 5)
+ 4 * $longname 6; Use this indentation method
$longName 1 = $longName 2 * ($longName 3 + $longName 4
-$longName 5) + 4 * $longname 6; Avoid this
The following is an example of two indentation method declarations. The former is a conventional case. The latter, if used in normal indentation, will move the second and third rows to the right, so instead indent 8 spaces
The traditional indentation method
function SomeMethod ($ANARG, $anotherArg, $YETANOTHERARG,
$andStillAnother) {
...
}
Use 8 consecutive spaces to avoid indentation of transitions
function Horkinglongmethodname ($ANARG,
$anotherArg, $yetAnotherArg,
$andStillAnother) {
...
}
The wrapping of an if statement usually uses a 8-space rule, because a regular indent (4 spaces) makes the statement body look more laborious. Like what:
Do not use this indentation method
if ((Condition1 && condition2)
|| (Condition3 && Condition4)
||! (Condition5 && Condition6)) {//Wrong line wrapping, no indentation
Dosomethingaboutit (); The condition is aligned with this sentence, causing the reading program to miss this sentence.
}
You should use this indentation method
if ((Condition1 && condition2)
|| (Condition3 && Condition4)
||! (Condition5 && Condition6)) {
Dosomethingaboutit ();
}
Or this indentation way can also
if ((condition1 && condition2) | | (Condition3 && Condition4)
||! (Condition5 && Condition6)) {
Dosomethingaboutit ();
}
Here are three possible ways to deal with ternary expressions:
$alpha = (alongbooleanexpression)? Beta:gamma;
$alpha = (alongbooleanexpression)? Beta
: Gamma;
$alpha = (alongbooleanexpression)
? Beta
: Gamma;
Download PHP Code specification CHM
Http://down.111cn.net/down/help/php/2009/0301/phpchm.html
Better in various programming online Help manuals please go to
http://111cn.net/help/View