for($ey=$y-4,$a=0;$ey!=$y+5;$ey++)
for($ex=$x-4;$ex!=$x+5;$ex++,$a++)
if($row[0] == $ex && $row[1] == $ey)
$critters[a]++;
OR
for($ey=$y-4,$a=0;$ey!=$y+5;$ey++)
{
for($ex=$x-4;$ex!=$x+5;$ex++,$a++)
{
if($row[0] == $ex && $row[1] == $ey)
{
$critters[a]++;
Your code format
Moderator: General Moderators
Usually if you came from C++, you'd do your if, while, for's like:
But, if you came directly to PHP, like me, you'd use:
Code: Select all
<?php
if ($var == 1)
{
echo $var;
}
?>Code: Select all
<?php
if ($var == 1) {
echo $var;
}
?>Depending on how far i think i'm going to nest if...else stuff...
if ($blah) {
<tab>print "spoon\n";
}
if i've got something that spans multiple lines, i do the following:
if (!$_POST["polNumber"]) { $_SESSION["polNumber"]=NULL; unset($_SESSION["polNumber"]); $_SESSION["errPN"]=1; } else { $_SESSION["errPN"]=NULL; unset($_SESSION["errPN"]); $_SESSION["polNumber"]=$_POST["polNumber"]; }
if ($blah) {
<tab>print "spoon\n";
}
if i've got something that spans multiple lines, i do the following:
if (!$_POST["polNumber"]) { $_SESSION["polNumber"]=NULL; unset($_SESSION["polNumber"]); $_SESSION["errPN"]=1; } else { $_SESSION["errPN"]=NULL; unset($_SESSION["errPN"]); $_SESSION["polNumber"]=$_POST["polNumber"]; }
- Heavy
- Forum Contributor
- Posts: 478
- Joined: Sun Sep 22, 2002 7:36 am
- Location: Viksjöfors, Hälsingland, Sweden
- Contact:
I usually try to put the first character indented to be vertically below the first non symbol character after the reserved word. And I keep doing so through nested braces.
Also, I like to indent function content so that only the word "function" is to the left:
... at least using syntax hiliting it is easy to read... I think...
I hate tabs...
But I am still considering using them because I like to indent much, and tabs require less bytes.
Also, I like to indent function content so that only the word "function" is to the left:
Code: Select all
function MySub($blablabla){
$blabla = "$blablabla no way";
if (strlen($blabla) > 7){
echo "DUMB";
}elseif (is_float($blablabla)){
echo $blablabla / 4;
}else{
echo "$blablabla divided by 4";
}
$strSQL = "select passwords from databases all over the world!";
$result = mysql_query($strSQL);
while($row = mysql_fetch_array($result)){
echo "Password: {$rowї'pass']}<br>";
}
}I hate tabs...
But I am still considering using them because I like to indent much, and tabs require less bytes.
Takuma wrote:I've converted nearly all my spaces into tabs. I just thought the file size migh be smaller if I do this![]()
