PHP标签在PHP标签中,是否有其他选择?
如果用户处于特定的级别,我想回显一组html代码。但我犯了个错误 分析错误:语法错误,意外的“?” PHP代码PHP标签在PHP标签中,是否有其他选择?,php,html,Php,Html,如果用户处于特定的级别,我想回显一组html代码。但我犯了个错误 分析错误:语法错误,意外的“?” PHP代码 <?php if ($row['rank'] == 0) { echo ' //SOME CODE HERE <label>Question 1: </label> <input class="au-input au-input--full" style="width: 50%;" t
<?php if ($row['rank'] == 0) { echo '
//SOME CODE HERE
<label>Question 1: </label>
<input class="au-input au-input--full" style="width: 50%;" type="text" name="question1" placeholder="Question 1" value="' . $question1 . '"></input>
<input type="checkbox" name="q1multiple"' <?php if(isset($_POST['q1multiple'])) { echo "checked='checked'"; } ?> '>
<label>Allow more than one answer </label>
</div>
//SOME CODE HERE
end of echo';} ?>
错误在if(isset($_POST['q1multiple']){echo“checked='checked'”部分中
我应该怎么做?你应该学习PHP的基础知识,你在
echo
中,不要打开你应该学习PHP的基础知识,你在echo
中,不要打开你不能在PHP
标记中做标记。
使用一个简短的if命令进行尝试,如:
(isset($\u POST['q1multiple'])?“checked=”checked“:“”)
下面是您的代码修复程序:
<?php if ($row['rank'] == 0) { echo '
//SOME CODE HERE
<label>Question 1: </label>
<input class="au-input au-input--full" style="width: 50%;" type="text" name="question1" placeholder="Question 1" value="' . $question1 . '"></input>
<input type="checkbox" name="q1multiple"' . (isset($_POST['q1multiple']) ? 'checked="checked"' : '') . '>
<label>Allow more than one answer </label>
</div>
//SOME CODE HERE
end of echo';} ?>
您不能在PHP
-tag中执行PHP
标记。
使用一个简短的if命令进行尝试,如:
(isset($\u POST['q1multiple'])?“checked=”checked“:“”)
下面是您的代码修复程序:
<?php if ($row['rank'] == 0) { echo '
//SOME CODE HERE
<label>Question 1: </label>
<input class="au-input au-input--full" style="width: 50%;" type="text" name="question1" placeholder="Question 1" value="' . $question1 . '"></input>
<input type="checkbox" name="q1multiple"' . (isset($_POST['q1multiple']) ? 'checked="checked"' : '') . '>
<label>Allow more than one answer </label>
</div>
//SOME CODE HERE
end of echo';} ?>
什么是some code
PHP或html?什么是some code
PHP或html?这解决了问题,但解释不是问题所在!非常感谢。有人能给我解释一下“?”和“:”)的意思吗?这样我也可以学习。:@James Ocampo它被称为“三元运算符”。你可以在PHP文档中找到有关它的信息。这基本上是编写简单的“如果”语句的一种简单方法。这解决了问题,但解释不是问题所在。非常感谢。有人能向我解释一下“?”和“:”)的意思是什么吗?这样我也可以学习。:@James Ocampo它被称为“三元运算符”。您可以在PHP文档中找到有关它的信息。这基本上是编写简单的“if”的一种简单方法“语句谢谢,我在echo外部创建了html代码,并决定将其放入echo中,我的错。谢谢。谢谢,我在echo外部创建了html代码,并决定将其放入echo中,我的错。谢谢。