README.md

December 4, 2022 · View on GitHub

Proper Indentation

Description

Teaches the basics of Proper Indentation in your php source.

More Info

Submitted On
BySteve Oliver
LevelBeginner
User Rating4.3 (26 globes from 6 users)
CompatibilityPHP 3.0, PHP 4.0
CategoryCoding Standards
WorldPHP
Archive File

Source Code

I think it is a basic coding standard to Indent each function, loop, etc. This not only helps others that may be working with your source, But it also helps when you go back and look at your source. Below are some examples of right and wrong.

wrong way:
if(foo==""){var="1");}
should be:
if(foo=="")<br> {<br> &nbsp;&nbsp;&nbsp;var="1";
}

wrong way:
While(List(blah)=mysqlfetchrow(blah)=mysql_fetch_row(results)){
if(blah==""){echo blah;}else{echo "none";}}

should be:
While(List(blah)=mysqlfetchrow(blah)=mysql_fetch_row(results))
{
 if(blah=="")<br> &nbsp;{<br> &nbsp;&nbsp;&nbsp;echo blah;
 }
 else
 {
   echo "none";
 }
}

wrong way:
function doit(var){<br> if(var==""){var="false";}else{var="true";}
return var;}<br> <br> should be:<br> function doit(var)
{
 if(var=="")<br> &nbsp;{<br> &nbsp;&nbsp;&nbsp;var="false";
 }
 else
 {
   var="true";<br> &nbsp;}<br> &nbsp;return var;
}

I think you get the basic Idea. Although it may seem long and drawn out, trust me, it will help you in the long run.

-Steve