Jump to content

Indentation, Structuring


Recommended Posts

To ensure good coding habits and techniques, are there any articles discussing good coding, nesting, and/or structuring habits to help keep my pages neat and lean? Or any considerations you guys do to keep things looking clean for your pages?

Link to comment
Share on other sites

Most importantly, be sure to put each level of code on a new level of indentation.This is really difficult to read:

if(count($a) > 0) {echo "<div class='c'>";foreach($a as $x=>$n) {echo "$x: $n\n";}echo "</div>";}

This is much better:

if(count($a) > 0) {  echo "<div class='c'>";  foreach($a as $x=>$n) {	echo "$x: $n\n";  }  echo "</div>";}

Also, it's good to put comments frequently explaining what each portion of code is, so that if you have to go back to it, you'll know what it's doing.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...