To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here
PHPBuilder.com  
 

 

Go Back   PHPBuilder.com > Discussion > Echo Lounge

Echo Lounge General Chat and Introductions. A catch all for any topic.

Reply
 
Thread Tools Rate Thread Display Modes
Old 10-10-2002, 02:30 PM   #1
Sxooter
Chamberlain
 
Sxooter's Avatar
 
Join Date: Aug 2002
Location: Denver, CO
Posts: 4,056
Indentaion Style

So, how do you guys indent (if you do hehe) your code. Mine is:

tab=8 spaces (remain tabs though)
style:
Code:
function name (args,args) {
        first level;
        if (something==something){
                next line;
        }
}
How about the rest of ya?
__________________
PostgreSQL version 8.4 is now in beta! New features in the works: Updateable Views, WITH queries including recursive, On-disk bitmap indexes, and improved partitioning. woot!

Last edited by Sxooter; 10-10-2002 at 04:42 PM.
Sxooter is offline   Reply With Quote
Old 10-10-2002, 04:04 PM   #2
examancer
Seniorest Member
 
examancer's Avatar
 
Join Date: Mar 2002
Location: Omaha, NE
Posts: 256
looks like you forgot the closing [/code] tag.

I indent using 2 spaces, not tab. Here is a function I made:

PHP Code:
// sytax: string dump_array(mixed $value [, string $value_boundary [, string $key_boundary [, int $r_flag]]])
// dumps the array into "key : value" pairs recursively:
// argument 1 is required, and can be any variable type... but if its an array, it will be dumped recursively.
// argument 2 is optional and is a string. This string is the boundary between values. the default is " : "
// argument 3 is optional and is a string. This string is the boundary between the keys. The default is "<br>";
// argument 4 is optional and is a number. 1 means that the function call is a recursive one, and not the original.
// argument 4 is for internal function use only and should not be set in the original function call from the script.
function dump_array ($x) {
  if (
gettype($x) == "array") { // if value is an array...
    // then the value is split into key:value pairs, which are each sent back through the function
    // to make sure they are not arrays themseles... and if they are, they are split again, and again, and again, etc...
    
$vb = ' : ';  // default boundary that seperates values from each other and their key.
    
$kb = '<br>'; // default boundary that seperates keys.
    
if (func_num_args() > 1) { // if arg 2 is set...
      
$vb = func_get_arg(1);  // the value replaces the default value boundary.
      
if (func_num_args() > 2) { // if arg 3 is set...
        
$kb = func_get_arg(2); // the value replaces the default key boundary.
      
}
    }
    
/*if (func_num_args() > 3 && func_get_arg(3) == 1) { // if the function call is a recursive one...
      $kb = $vb; // the key boundary is removed, since the key is really just a value for another key.
    }*/
    
while ($a = each($x)) { // walks through the key:value pairs for each key in the current array.
      // a string containing all the key:value pairs is generated:
      // - both the key and the value are sent back through the function to ensure they are not arrays.
      
if (func_num_args() > 3 && func_get_arg(3) == 1) {
        @
$table .= '(' . dump_array($a[0], $vb, $kb, 1) . $vb . dump_array($a[1], $vb, $kb, 1) . ')';
      } else {
        @
$table .= dump_array($a[0], $vb, $kb, 1) . $vb . dump_array($a[1], $vb, $kb, 1) . $kb;
      }
    }
    return
$table;
  } else {
// if value is not an array, the value is returned untouched.
    
return $x;
  }
}
its a nice little function I keep around to check the content of arrays.
__________________
Examancer - current project: Link Leaf
examancer is offline   Reply With Quote
Old 10-11-2002, 11:53 AM   #3
largo
Senior Member
 
Join Date: Aug 2002
Posts: 173
I use the following standard Sxooter:

http://pear.php.net/manual/en/standa...ards.indenting

8 spaces (for tab) is a bit much.... though default for most editors.

-m.
largo is offline   Reply With Quote
Old 10-11-2002, 05:56 PM   #4
Sxooter
Chamberlain
 
Sxooter's Avatar
 
Join Date: Aug 2002
Location: Denver, CO
Posts: 4,056
The reasoning for 8 spaces is that if you find yourself having a hard time reading the code because it's so indented, it's time to break your code apart into more manageable pieces. 8 spaces, by the way, is also the standard for the Linux kernel. Just fyi.
__________________
PostgreSQL version 8.4 is now in beta! New features in the works: Updateable Views, WITH queries including recursive, On-disk bitmap indexes, and improved partitioning. woot!
Sxooter is offline   Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 07:17 AM.






Acceptable Use Policy

internet.comMediabistrojusttechjobs.comGraphics.com

WebMediaBrands Corporate Info


Advertise | Newsletters | Feedback | Submit News

Legal Notices | Licensing | Permissions | Privacy Policy


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.