PHP单引号跟双引号对待变量的不同
PHP单引号和双引号对待变量的不同
如果一个变量放在单引号中,会被当作字符串来处理,如果是放在双引号中,则会被当值一个变量来处理(此时可以用 {}扩起来,也可以不用)。
1 <?php 2 $txt = "hello, this is from txt"; 3 echo 'the word is {$txt}'; //the word is {$txt} 4 echo "the word is {$txt}"; //the word is hello, this is from txt