我试图在循环中保存一些结果,然后将名为$ hello的外部变量修改为'123',然后在循环外面打印它。
$hello = 'hi';
// SQL //
if ($stmt = $this->dbCon->prepare($sql)) {
//$stmt->bind_param("s", $chainid);
call_user_func_array(array($stmt, 'bind_param'), $params);
$stmt->execute();
$stmt->bind_result($sysid, $branchid, $harddiscount);
while ($stmt->fetch()) {
$harddiscount = number_format($harddiscount / 100, 2) . "€";
//echo $couponname ."*".$trustanduseid."({$clientid})*".$productname."*".$chainname."*".$branchname."*".$receiptdate."*".$companyname."*".$brandname."*".$receiptid."*".$counterid."*".$discountvalue."*";
//echo $couponname ."*".$trustanduseid."({$clientid})*".$productname."*".$chainname."*".$branchname."*".$receiptdate."*".$companyname."*".$brandname."*".$receiptid."*".$counterid."*".$harddiscount."*";
$hello = '123';
}
$stmt->close();
}
echo $hello;
上面打印'hi'而不是'123';
我怎样才能解决它?