1. Home
  2. Docs
  3. PHP Style Guide
  4. Bracket and Parenthetic Spacing

Bracket and Parenthetic Spacing

In general, parenthesis and brackets should not use any additional spaces. The exception is that a space should always follow PHP control structures that accept arguments with parenthesis (declare, do-while, elseif, for, foreach, if, switch, while), to help distinguish them from functions and increase readability.

INCORRECT:

CORRECT:

INCORRECT:

CORRECT:

INCORRECT:

CORRECT:

Was this article helpful to you? Yes No

How can we help?