无法在html中运行PHP脚本
当我的特定条件得到满足时,我一直试图在无法在html中运行PHP脚本,php,Php,当我的特定条件得到满足时,我一直试图在标记之间显示内容。最初,我有一个$result字符串,试图在其中检查条件。但我想我在语法上做错了。 我的代码: $Result1= ' 名称:。$username htmlspecialchars(“”); 能力6-提供优惠:'.round($per_s6,2)。' htmlspecialchars('); '; 我想这三行是不正确的 echo htmlspecialchars('<? if($tips_flag == 1){'); <li
标记之间显示内容。最初,我有一个$result字符串,试图在其中检查条件。但我想我在语法上做错了。
我的代码:
$Result1=
'
- 名称:。$username
htmlspecialchars(“”);
- 能力6-提供优惠:'.round($per_s6,2)。'
htmlspecialchars(');
';
我想这三行是不正确的
echo htmlspecialchars('<? if($tips_flag == 1){');
<li >Competency 6 - Offer concessions: '.round($per_s6, 2).' percent</li>
echo htmlspecialchars('<? } ?>)';
echo htmlspecialchars(');
救命啊 我想这正是你所追求的(但不确定htmlspecialchars)
$html\u附加内容=($tips\u标志==1)?”能力6-提供优惠:'。每轮(2美元)百分比:'';
$Result1=
'
- 名称:。$username.
”$html_附加内容。'
';
第一行是使用三元运算符的条件行。另外,请确保您的变量已分配。在语法方面,有两件事情是错误的。我不确定这段代码在做什么,但从语法角度看,这是错误的:
$Result1 =
'<div id="midrow">
<ul class="rounded-list">
<li ><strong>Name:</strong> '.$username.'</li> //you need to put a '; here
echo htmlspecialchars('<? if($tips_flag == 1){'); //why do you have php
//opening there?
//here you need to do echo '
<li >Competency 6 - Offer concessions: '.round($per_s6, 2).' percent</li>
//you need '; here to end the single tick with a semicolon
echo htmlspecialchars('<? } ?>)';
//you need echo ' here again
</ul>
</div>';
$Result1=
'
- 名称:。$username.
//您需要输入一个“;在这里
回显htmlspecialchars(');
//你需要再次在这里回音
';
> p>不能在级联字符串的中间打开和关闭标记(<代码> <代码>)。您也不能在其中放置if
块
$Result1 =
'<div id="midrow">
<ul class="rounded-list">
<li ><strong>Name:</strong> ' . $username . '</li>';
if($tips_flag == 1) {
$Result1 .='<li >Competency 6 - Offer concessions: '.round($per_s6, 2).' percent</li>';
}
$Result1 .= '</ul>
</div>';
$Result1=
'
- 名称:”$用户名。”李>';
如果($tips\u flag==1){
$Result1.='
- 能力6-提供优惠:'.round($per_s6,2)。'percent
;
}
$Result1.='
';
您无法在变量赋值中回送。已删除回送,但仍然没有成功使用htmlspecialchars()
您想做什么?你现在所拥有的只是简单的文字;它不会作为PHP执行,因为您将它作为字符串参数传递。
$Result1 =
'<div id="midrow">
<ul class="rounded-list">
<li ><strong>Name:</strong> '.$username.'</li> //you need to put a '; here
echo htmlspecialchars('<? if($tips_flag == 1){'); //why do you have php
//opening there?
//here you need to do echo '
<li >Competency 6 - Offer concessions: '.round($per_s6, 2).' percent</li>
//you need '; here to end the single tick with a semicolon
echo htmlspecialchars('<? } ?>)';
//you need echo ' here again
</ul>
</div>';
$Result1 =
'<div id="midrow">
<ul class="rounded-list">
<li ><strong>Name:</strong> ' . $username . '</li>';
if($tips_flag == 1) {
$Result1 .='<li >Competency 6 - Offer concessions: '.round($per_s6, 2).' percent</li>';
}
$Result1 .= '</ul>
</div>';