Re: PHP String convention

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/10/28 Jim Lucas:
> Nick Cooper wrote:
>> Hi,
>>
>> I was just wondering what the difference/advantage of these two
>> methods of writing a string are:
>>
>> 1) $string = "foo{$bar}";
>>
>> 2) $string = 'foo'.$bar;
>>
>> I always use method 2 but have been noticing method 1 more and more in
>> source code. Is this just user preference?
>>
>> I would use a generic search engine but not sure what the first method
>> is called so don't know where to begin my search.
>>
>> Thanks for any help.
>>
>> Nick
>>
>
> I think it is a matter of personal preference.  I prefer method 1 myself.
>
>
>

Thank you for the quick replies. I thought method 2 must be faster
because it doesn't have to search for variables in the string.

So what is the advantages then of method 1 over 3, do the curly braces
mean anything?

1) $string = "foo{$bar}";

2) $string = 'foo'.$bar;

3) $string = "foo$bar";

I must admit reading method 1 is easier, but writing method 2 is
quicker, is that the only purpose the curly braces serve?

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux