12-31-2007, 05:16 PM
|
#10 (permalink)
|
|
Moderateur
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
|
I'm very anal about laying out of code. Pretty much all strings are wrapped in single quotes; concatenating strings and variables with single spaces between the string and variable, and variable and string (or two variables, or whatever). Basically:
PHP Code:
// Me likey $string = 'This string is ' . $colour;
// Me no likey $string = 'This string is '.$colour; $string = 'This string is '. $colour; $string = 'This string is ' .$colour; $string = "This string is $colour";
// Evil! $var = 'colour'; $string = "This string is ${$var}";
// Super Evil! Even worse than the above!! $string = "This string is " . $colour;
Also, since there has been a fair amount of echoing concatenated strings in this topic: remember that you can separate expressions with a comma when using echo!
PHP Code:
echo 'This string is' . $colour; echo 'This string is', $colour;
The latter (with commas) forgoes the overhead of first concatenating the elements together into one long (in relative terms) string then echoing it, in favour of outputting a series of smaller strings: the upshot being that it is marginally faster to process. 
|
|
|
|