Re: Coding Standards: Syntax and identation
| From: | Arni Arent | Date: | Sat, 02 Dec 2000 21:52:22 +0000 |
| Subject: | Re: Coding Standards: Syntax and identation | ||
| References: | 1 | Groups: | php.pear |
| Request: | Send a blank email to php-pear+get-471@lists.php.net to get a copy of this message | ||
Negative,
I would always use // to comment single or multiple lines. In some cases
I have to comment out a lot of code, then I could use /* and */ to
comment out the code, even if the code contains //.
E.g.
/*
// This is a comment.
some php functionality.
// Another comment.
another php functionality.
*/
Regards.
Ulf Wendel wrote:
>
> Hi,
>
> does PEAR overtake the PHP Coding Standards when it comes to syntax and
> identation?
>
> PHP 4 CODING_STANDARDS:
> < Syntax and indentation
> < ----------------------
> <
> < [1] Never use C++ style comments (i.e. // comment). Always use
> C-style
> < comments instead. PHP is written in C, and is aimed at
> compiling...
>
> That means I should use this style, right?
>
> /* one line comment */
>
> /*
> multi
> line
> comment
> */
>
> < [2] Use K&R-style. Of course, we can't and don't want to
> < force anybody to use a style he or she is not used to, but,
> < at the very least, when you write code that goes into the core
> < of PHP or one of its standard modules, please maintain the K&R
> < style. This applies to just about everything, starting with
> < indentation and comment styles and up to function decleration
> < syntax.
>
> Is that a must if it comes to curly braces? I preferr the BSD style
> instead of the K&R one. This is K&R:
>
> function foo($param)
> {
>
> if ( "" != $param )
> print "\$param is no an empty string.";
> else {
> print "\$param";
> print " is an empty string.";
> }
>
> }
>
> This is what I preferr:
>
> function foo($param) {
> ...
> }
>
>
> < [3] Be generous with whitespace and braces. Always prefer:
> <
> < if (foo) {
> < bar;
> < }
> <
> < to:
> <
> < if(foo)bar;
>
> Hmm, what about:
>
> if ($foo)
> bar();
>
> < Keep one empty line between the variable decleration section and
>
> Is there any rule on this for PHP code.
>
> < the statements in a block, as well as between logical statement
>
> How about operators. Do I have to insert spaces around an operator such
> as: print $bar + $foo;
>
> < groups in a block. Maintain at least one empty line between
> < two functions, preferably two.
> <
> <[4] When indenting, use the tab character. A tab is expected to
> represent
> < four spaces. It is important to maintain consistency in indenture
> so
> < that definitions, comments, and control structures line up
> correctly.
>
> I used tabs with a width of 2 spaces in PHPDoc, was that a good idea?
>
> Ulf
>
> --
> PHP Extension and Add-on Repository (PEAR) mailing list.
> Documentation can be found at http://pear.php.net/doc/pear.html
> To unsubscribe, e-mail: php-pear-unsubscribe@lists.php.net from the
> mail address you subscribed with.
--
--------------------------------------------------
Arni Arent arni@firmanet.is Senior Web Developer
--------------------------------------------------
Firmanet ehf.
http://www.firmanet.is
Sudurhlid 35, 105 Reykjavik, ICELAND
Phone: (+354) 588 0019, Fax: (+354) 552 2195
--------------------------------------------------
Official Red Hat distributor and Arkeia reseller
--------------------------------------------------