我第一次搜索如何使用PHP连接数据库时,偶然发现了以下示例:

mysql_connect("$host", "$username", "$password");

但那和这有什么区别呢?
mysql_connect($host, $username, $password);

最佳答案

实际上从用户角度看没有什么不同。双引号中的变量将被计算,因此;

$hello="world";
$world="hello";
echo "$hello $world"

将打印“世界你好”。
此功能允许您
"$very $annoying $string"
而不是
$very." ".$annoying." ".$string
这就像shell脚本(如果您熟悉shell脚本)。

关于php - 这两者之间的区别...?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6467023/

10-15 21:40