Tag Archives: Lincoln cent

PHP Coding Style: Large IF Statements

Have you ever seen some PHP code like that:

1
2
3
if ($condition1 && $condition2 && $string1 == $string2 . $string3 && $string4 != $string5 . $string6) {
   // write some code here!?
}

It is ugly, isn’t it?

I’d prefer to make it clearer! What about that?

1
2
3
4
5
6
7
8
9
if ($condition1 
   && $condition2
   && $string1 == $string2
                . $string3
   && $string4 != $string5
                . $string6
) {
   // write some code here
}