Well, it depends on how the programmers code. Like mentioned on this thread earlier, since there are no official standards, programmers have free reign. Consider this:
// Technique 1
function foo() {
echo "Bar";
}
// Technique 2
function foo()
{
echo "Bar";
}
I myself subscribe to the technique 2 style of coding - I don't like my brackets directly after statements, I like them on separate lines. But it doesn't inhibit me from reading the code. Something that'd make it difficult for me to read/debug would be a programmer who removes all comments, whitespaces, tabs, and linebreaks:
function reallyComplicated($var1="test",$var2) { echo $var1 . "<br>" . $var2; if ($var1 == $var2) { echo "Yes"; } else { echo "No"; } $sql = "select * from foo where bar='$var1'"; $result = mysql_query($sql) or die("Complicated function failed miserably!"); if (mysql_num_rows($result) > 0) { if (mysql_num_rows($result) > 1) { echo "SQL injection-guy"; } else { echo "Correct!"; } } else { echo "Wrong"; } }
/** reallyComplicated(str var1[, str var2="test"])
* Accepts - two parameters. Default for second is "test".
* Returns - nothing
**/
function reallyComplicated($var1,$var2="test")
{
echo $var1 . "<br>" . $var2; // Echo the variables for confirmation
if ($var1 == $var2) // Check to see if they're the same
{
echo "Yes"; // If so, say so
}
else
{
echo "No"; // If not, say so
}
$sql = "SELECT * FROM foo WHERE bar='$var1'"; // Generate SQL query
$result = mysql_query($sql) or die("Complicated function failed miserably!"); // Query DB and nicely exit from error
if (mysql_num_rows($result) > 0) // If there's more than 0 rows returned...
{
if (mysql_num_rows($result) > 1) // If there's more than 1 rows returned, SQL injection! head for the hills!
{
echo "SQL injection-guy";
} // End if
else // Only 1 row returned. Perfect
{
echo "Correct!";
} // End else
} // End if
else // No rows returned. Wrong var1.
{
echo "Wrong";
} // End else
} // End function
See the difference? much easier to read!