在一个函数中,我想使用一个 if 语句来查找一个 mysqlibind_result()
变量if($qandaReplyType == 'Single'){
,但是在尝试这个时我得到了一个未定义的变量。我查看了一些 SO 示例,但我不明白如何正确实现它。所以我的问题是,有人可以提供一个代码片段以便能够修复错误,还可以让我了解如何在函数中检索 mysqli 变量以供将来使用,并让我充分了解它应该如何书面。
代码:
$qandaquery = "SELECT q.QuestionId ReplyType
FROM QuestionId q
INNER JOIN Reply r ON q.ReplyId = r.ReplyId
...
$qandaqrystmt->bind_result($qandaQuestionId,$qandaReplyType);
$arrReplyType = array();
while ($qandaqrystmt->fetch()) {
$arrReplyType[ $qandaQuestionId ] = $qandaReplyType;
}
$qandaqrystmt->close();
function ExpandOptionType($option) {
...
foreach($options as $indivOption) {
if($qandaReplyType == 'Single'){
...
}
else if ($qandaReplyType == 'Multiple'){
...
}
}
}
试图:
var $reply;
function ExpandOptionType($qandaReplyType) {
$this->reply = $qandaReplyType;
if($qandaReplyType == 'Single'){
...
}
}else if($qandaReplyType == 'Multiple'){
... }
}
}