如果一个变量放在单引号中,会被当作字符串来处理,如果是放在双引号中,则会被当值一个变量来处理(此时可以用 {}扩起来,也可以不用). <?php $txt = "hello, this is from txt"; echo 'the word is {$txt}'; //the word is {$txt} echo "the word is {$txt}"; //the word is hello, this is from txt…
[1]单引号和双引号在处理变量的时候做法: 括在双引号内的变量会解释出值,但是括在单引号内则不做处理,直接输出: <?php $var = 'my name is huige'; echo "$var"; //结果是:my name is huige echo '$var'; //结果是:$var ?> [2]如果在语句中要转义操作,那么就一定要用双引号了. 比如,转定义单引号时,写成这样的话: $a = ‘He\’s name is Huige.’ ; 程序会把He\’s…