TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   A space or not? (http://www.talkphp.com/absolute-beginners/1876-space-not.html)

Karl 01-06-2008 03:55 PM

A space or not?
 
OK, maybe it's just me, but I'm sick of people not adding a space after their if/else/while/etc. keywords. It really annoys me, it's not a function, so add a bloody space!

Just curious, where does everyone stand on this issue? I'm expecting to be a minority here, it seems everywhere I look people are omitting those spaces.

Example:

PHP Code:

if($something SOMETHING_FLAG

compared to:

PHP Code:

if ($something SOMETHING_FLAG


YouNeek 01-06-2008 04:08 PM

Personally I used to not add a space but in recent months I've decided it makes the code look a lot tidier and more conventional. It doesn't bother me if people don't, but I think it always looks nicer if people do.

short 01-06-2008 04:14 PM

PHP Code:

if ( $something SOMETHING_FLAG 

that's the only right thing to do :)

Wildhoney 01-06-2008 04:16 PM

You're twisting things, short! :-) I don't often put a space, but then again I don't pay much attention to the possibility of a space there. Zend actually gives me a space automatically if I press tab on the autocomplete list, but I tend to type them all myself and keep well away from the tab.

TlcAndres 01-06-2008 05:07 PM

It seems once again I've committed an error haha, I'll make sure to keep the space in mind from now on.

Aaron 01-06-2008 06:06 PM

It is just personal preference... I like to style my if's like below:
PHP Code:

if(2){
   echo 
"LIES!";
}else(
   echo 
"MORE LIES!";



Karl 01-06-2008 07:13 PM

Yeh there is no right or wrong way, I just like to rant. Although, of course, I would say my way is the right way :-)

Andrew 01-06-2008 08:27 PM

Also, I like adding the space, as it's more flowing. You don't do: (Well, most don't do:)
PHP Code:

$var='var'

So if you add a space between those, and all the loops/statements, then it just looks a lot better, not so cramped.

xenon 01-06-2008 08:41 PM

I personally hate space after language constructs. I use this style:

PHP Code:

if( $something SOMETHING_FLAG )
{
    
// do stuff...


But then again, it's a matter of preference... And about the poll, the 2nd option is not fair at all.

bluesaga 01-06-2008 09:14 PM

always done it without the space, strange. It annoys me when things arent lined up (and really make things less usable to make them look nicer....) But that has never bugged me, strange that!

Karl 01-06-2008 09:33 PM

Quote:

Originally Posted by xenon (Post 7791)
And about the poll, the 2nd option is not fair at all.

Lol, no it isn't, I shall even the playing field :-)

Salathe 01-06-2008 10:44 PM

I generally (note: not always as there are exceptions!) follow the idea of adding a space between language construct and opening parenthesis, and no space between function name and opening parenthesis. That's always true for functions, but I commonly neglect the space for isset/unset/empty and probably some others that my mind doesn't want to conjure up at this moment.

Back to the original poll question, I always add a space after if, else, while and for. (Note: if you ever see code from me without that space, don't shoot me. It's likely just a typing mistake.)

Village Idiot 01-07-2008 04:58 AM

No, I find it easier to read with no space.


All times are GMT. The time now is 09:11 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0