意外的T_Variable错误,是什么导致它循环?

时间:2013-02-06 02:39:01

标签: php

我收到错误声明:

解析错误:语法错误,第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;

}
?>

1 个答案:

答案 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;