如果一个变量放在单引号中,会被当作字符串来处理,如果是放在双引号中,则会被当值一个变量来处理(此时可以用 {}扩起来,也可以不用)。
<?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
如果一个变量放在单引号中,会被当作字符串来处理,如果是放在双引号中,则会被当值一个变量来处理(此时可以用 {}扩起来,也可以不用)。
<?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