我无法弄清楚如何在HTML链接中包含变量;这个链接本身就是一个变量。我的引号工作正常,直到我尝试添加$ ou。有什么想法吗?
$mout = '<img src="http://www.example-website.com/header.jpg" width="600px" height="101px" alt="header" /><br />Click on the following link to confirm your registration:<br /><a href="Http://example-website.com/coupon.php?o=' . $ou'">Confirm</a>';
答案 0 :(得分:6)
$mout = '<img src="http://www.example-website.com/header.jpg" width="600px" height="101px" alt="header" /><br />Click on the following link to confirm your registration:<br /><a href="Http://example-website.com/coupon.php?o=' . $ou . '">Confirm</a>';
答案 1 :(得分:2)
虽然上面的示例非常精细,但在使用双引号时,您可以在字符串中包含变量,例如:
$ foo =“bar”;
echo“这是一个变量:$ foo”;
将输出:
这是一个变量:bar
但是,对于单引号,您需要关闭引号并附加变量,如下所示:
echo'这是一个变量:'。 $ foo的;
此外,使用记住,如果要包含反斜杠,可以使用反斜杠转义引号。
例如:
$ foo =“此字符串包含\”Double-Quotes!\“”;
echo $ foo;
输出
此字符串包含“Double-Quotes!”;
答案 2 :(得分:1)
' . $ou . '
答案 3 :(得分:1)
'...coupon.php?o='.$ou.'">Confirm</a>';
你错过了一个点