-5

When echoing on a php some html commands that will be used to build the website, what is the difference between these 2?

4

3 回答 3

2

引号之间没有任何内容,也不会做任何有用的事情。我想您是在谈论使用不同的引号类型来围绕字符串。最显着的区别是双引号做变量插值和转义,而单引号字符串不做。例如:

$num = 5;
echo 'You have $num apples.\n'; // You have $num apples.\n
echo "You have $num apples.\n"; // You have 5 apples.[newline]

不过,单引号确实会在某些情况下解释转义:

echo 'It\'s interpreting these backslash \\ escapes.';
// It's interpreting these backslash \ escapes.
于 2012-05-26T06:26:33.677 回答
0

如果使用双引号,php 将解释变量名,例如 $var 作为变量名并输出或回显变量值。

如果使用单引号,php 会将其视为普通字符串。

$name = "Jane";

echo 'Hello $name'; // output is Hello $name
echo "Hello $name"; // output is Hello Jane
于 2012-05-26T09:38:30.863 回答
0

如果您的问题是关于回声快捷方式,

可能你需要看这个手册http://php.net/manual/en/function.echo.php

于 2012-05-26T06:32:23.017 回答