我收到错误声明:
解析错误:语法错误,第599行中的意外T_VARIABLE
属于以下行:
foreach ($questions as $key=>$question) {
echo '<p><strong>Question:</strong> ' .htmlspecialchars($row_question['question_num'][$key]). ': ' .htmlspecialchars($row_question['question_content']$key]). '</p>' . PHP_EOL;
}
我做错了什么?
以下是代码:
$question = array();
while ($selectedstudentanswerstmt->fetch()) {
$row_question = array();
$row_question['question_num'] = $detailsQuestionNo;
$row_question['question_content'] = $detailsQuestionContent;
$row_question['question_option'] = $detailsOptionType;
$row_question['question_num_answers'] = $detailsNoofAnswers;
$row_question['question_answer'] = $detailsAnswer;
$row_question['questionnum_reply'] = $detailsReplyType;
$row_question['questionnum_marks'] = $detailsQuestionMarks;
$questions[] = $row_question;
}
.................
<?php
foreach ($questions as $key=>$question) {
echo '<p><strong>Question:</strong> ' .htmlspecialchars($row_question['question_num'][$key]). ': ' .htmlspecialchars($row_question['question_content']$key]). '</p>' . PHP_EOL;
}
?>
答案 0 :(得分:3)
你错过了一个括号
echo '<p><strong>Question:</strong> ' .htmlspecialchars($row_question['question_num'][$key]). ': ' .htmlspecialchars($row_question['question_content']$key]). '</p>' . PHP_EOL;
应该是
echo '<p><strong>Question:</strong> ' .htmlspecialchars($row_question['question_num'][$key]). ': ' .htmlspecialchars($row_question['question_content'][$key]). '</p>' . PHP_EOL;