Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP标签在PHP标签中,是否有其他选择?_Php_Html - Fatal编程技术网

PHP标签在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

如果用户处于特定的级别,我想回显一组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%;" 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中,我的错。谢谢。