On Mon, Oct 27, 2003 at 09:38:32AM -0800, Justin Patrin wrote:
: 
: $query='Select * from users where userid="'.$_POST['userid'].'"';
: 
: I tend to use single quotes whenever I can and to use concatenation 
: instead of using in-string variables. I do this for three reasons. The 
: first is efficiency. Strings surrounded by single chars are not parsed 
: for any values, such as variables and backslashed characters (except for 
: '). This saves in execution time every time the script is executed.

No argument here, except that I don't know if the savings is really
noticable for such a small string.

: It also helps with readability of the code as some syntax highlighting
: doesn't catch variables in strings.

IMHO, in-string variables are more readable that trying to read
some-string-with-some-quote-character, dot, some-string, dot,
some-string, etc.

: The last reason is that I know 
: exactly what the code is going to do. I never really know what will be 
: used as the variable when I do it in a string. Will it follow a ->? What 
: about two? I don't always know and it's easier to debug without all of 
: the extra hassle.

That's what the curly brackets are for.

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

Reply via email to