我刚刚报名参加了Treehouse培训,我完成了这个迷你挑战。 我无法让这个工作。如果变量设置为' vanilla'我会得到一个成功的输出。但是,如果我使用饼干面团'然后我得到一个语法错误,我想这可能是因为在各种各样的事件中cookie和面团之间的空间?
<?php
$flavor = cookie dough;
echo "<p> Your favourite flavor is ";
echo $flavor;
echo ".</P>";
if ($flavor == "cookie dough") {
echo "<p> Yeah I like cookie dough aswell! </p>";
}
?>
答案 0 :(得分:2)
您忘了""
$flavor = cookie dough;
应该是
$flavor = "cookie dough";
^ ^
答案 1 :(得分:2)
用引号括起$flavor
变量值。
<?php
$flavor = "cookie dough";
echo "<p> Your favourite flavor is ";
echo $flavor;
echo ".</P>";
if ($flavor == "cookie dough") {
echo "<p> Yeah I like cookie dough aswell! </p>";
}
?>
答案 2 :(得分:1)
答案 3 :(得分:1)
$flavor = cookie dough;
应该是
$flavor = 'cookie dough';
或
$flavor = "cookie dough";
要定义字符串,您应该使用"'"
或'"'
;
答案 4 :(得分:1)
您忘记将cookie dough
括在引号中:
$flavor = "cookie dough";