添加其他参数时出现HTTP 500错误

时间:2017-08-13 19:47:06

标签: php mysql http web

我有以下功能:

 function displayData($array, &$htmlCode){
    $numOfQuestions = findNumOfQuestions($array);
    for($i = 1; $i <= $numOfQuestions; $i++){
        $htmlCode .= "<div class='question'><h2>Question: $i</h2>";
        foreach($array as $val){
            if(intval(substr($val, 0, 1)) == $i){
                $val = str_replace("$i > ", "", $val);
                $htmlCode .= $val.'<br>';
            }
        }
        $htmlCode .= "</div>";
    }
}

就此功能的功能而言,一切正常。除非我想在参数中添加另一个变量以便在函数中使用它,否则我会在xampp上遇到HTTP 500错误。

这就是我想要做的事情:

function displayData($array, &$htmlCode, $questions){
    // same function as one above just with another parameter
}

只是添加另一个参数会引发http 500错误,我不知道为什么......我在$ questions参数中输入的值是一个从MySQL数据库读入的字符串。我想使用$ questions变量在函数内部做其他事情,但我不能因为抛出错误。如果有人可以提供帮助,那就太棒了! :)

1 个答案:

答案 0 :(得分:0)

在调用方法时不要忘记添加参数。

相关问题