Ning Developer Docs

Just wanted to share a style of code-indentation that I've found to express clearly the logic of if statements and other control structures inside template files. That is, when PHP and HTML are mixed together, this technique can make it much clearer what's going on (in terms of nested structures, such as if statements, for loops, etc.).



You simply indent with each level of nesting, regardless of which language you are in; for example:



A simple example



This makes a dramatic difference with complex logic. For example:



Screenshot: Before



That if statement on line 18 - is it inside the for loop or not? Is it inside any other if statements?



Compare with:



Screenshot: After



Here the nesting is clear.

Views: 28

Comment

You need to be a member of Ning Developer Docs to add comments!

Join Ning Developer Docs

© 2024   Created by Ning Developer Admin.   Powered by

Badges  |  Report an Issue  |  Terms of Service