简体   繁体   中英

What's the difference between “string” .$var and “string $var” in php?

In preparing MySQL statements in PHP, I came across lines of codes like this:

$somequery = "some query '$var'";

Where $var is a variable containing a string.

What is the difference with the statement using the string concatenating operator . ?

$somequery = "some query " . $var;

The result string is actually the same. If there is any difference, when should I use the one over the other?

There is no difference in the output. The performance differences are negligible. Use whichever one looks nicer to you. Some prefer concatenation because syntax highlighters like it.

值是相同的,但只需使用一个可以让您自己或您授权的其他人轻松读取或调试代码的值!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM