Re: indent? [was: Comment block style]
| From: | Tomas V.V.Cox | Date: | Tue, 25 Sep 2001 23:06:52 +0000 |
| Subject: | Re: indent? [was: Comment block style] | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-2050@lists.php.net to get a copy of this message | ||
Nicolas Hoizey wrote:
>
> I've heard to much PEAR beginners say that this standard is bad and
> abandon it just because of the indenting part ... :(
>
I just can't understand why idententation is such a big problem. People
will find different coding standars in differents situations. Follow
them is so a horrible thing?
For the "tab or die" folks, perhaps my lame "tab to spaces" script could
help:
#!/usr/bin/php -Cq
<?php
$file = $argv[1];
($fd = @fopen($file, 'r')) or die ('Could not open');
$spaces = (@$argv[2] == 'stig') ? 8 : 4;
$spaces = str_repeat(' ', $spaces);
while ($line = fgets($fd, 1024)){
$line = str_replace("\t", $spaces, $line);
$l .= rtrim($line) . "\n";
}
fclose($fd);
$fd = @fopen($file, 'w');
fwrite($fd, $l);
fclose($fd);
?>
Use it with:
tab.php My_Class.php
will replace "4 column tabs" with 4 spaces and will auto strip trailing
white spaces for the same price. It's also accept a second special
parameter "stig" for replacing "8 column tabs" with 8 spaces:
tab.php My_Class.php stig
}:-)
Tomas V.V.Cox