开发者

learning about single and double quotes (.),("), and (')

开发者 https://www.devze.com 2023-01-15 03:40 出处:网络
Can you tell me what is the different using (\')single quotes i开发者_JAVA技巧nside (\")quotes and (\")quotes inside (\')single quotes? and at concat, what is the meaning of this \'\".$bla.\"\' I stil

Can you tell me what is the different using (')single quotes i开发者_JAVA技巧nside (")quotes and (")quotes inside (')single quotes? and at concat, what is the meaning of this '".$bla."' I still can not distinguish them.


In SQL, anything with single quotes is considered a text based data type.

SQL uses double quotes for escaping keywords and non-ASCII characters.

This:

'". $bla ."'

..is PHP syntax. $bla is a PHP variable, the period is a string concatenation character (which is why there's one on both sides). So in this example, the content of the $bla variable is being concatenated into a string, where it will be surrounded by single quotes.


The main difference is the anything in a double quote is evaluated and anything in a single quote is not. There has been some discussion that it is better to use single quotes than double quotes so that PHP does not need to evaluate every aspect of the line to determine if it is a variable or not:

$good = 'really good';

echo "this is not $good"; //bad
echo 'this is' . $good;  //good

It just keeps thing running faster and keeps the code looking cleaner.

0

精彩评论

暂无评论...
验证码 换一张
取 消