Netbeans 提示我将结果绑定(bind)到的变量未针对以下代码进行初始化。 最好将它们初始化为 NULL 之类的东西,还是我应该禁用提示?
if($statement) {
$statement->bind_param("i", $number);
$statement->execute();
$statement->bind_result($ID, $TS, $price, $quantity, $side, $ownerID,
$actingTraderID, $buyFee, $sellFee, $totalRight, $totalLeft);
$trades = [];
while($statement->fetch()) {
$trades[] = new Trade($ID, $TS, $price, $quantity, $side, $ownerID,
$actingTraderID, $buyFee, $sellFee, $totalRight, $totalLeft);
}
$statement->close();
}
最佳答案
bind_result()
通过引用接受参数,无需先创建和初始化它们。这适用于所有通过引用接受的变量,例如openssl_random_pseudo_bytes(32, $strong)
中的 $strong
被引用接受并用作附加“输出”,不需要先初始化。
关于php - 用于绑定(bind)预处理语句结果的变量是否应该先初始化?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33958433/