398   PHP

1,单引号的内容当做普通字符处理,换行符\n也会无效,当做字符输出
2,双引号的内容会检查是否有变量,然后进行替换;换行符有效;
3,由于双引号会做变量检查,所以效率比单引号低

$test = "1234";
echo "\n-------------\n";
echo 'val:$test';
echo "\n-------------\n";
echo ' row \n row';
echo "\n-------------\n";
echo "val:$test";
echo "\n-------------\n";
echo " row \n row";

// 输出
C:\Users\luckybird\Desktop\test>php test.php
-------------
val:$test
-------------
 row \n row
-------------
val:1234
-------------
 row
 row



Leave a Reply

Your email address will not be published. Required fields are marked *