Re: Re: Post variables and mysql queries
| From: | Eugene Lee | Date: | Mon, 27 Oct 2003 18:23:16 +0000 |
| Subject: | Re: Re: Post variables and mysql queries | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-167762@lists.php.net to get a copy of this message | ||
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.