官方文档 https://www.php.net/manual/zh/pdostatement.bindparam.php

注意: bindParam 第2个参数 mixed &$variable 是引用传值

正确的用法 ($val by reference):

<?php
foreach ($params as $key => &$val) {
    $sth->bindParam($key, $val);
}
?>

错误的用法 ($val by value, because bindParam needs &$variable):

<?php
foreach ($params as $key => $val) {
    $sth->bindParam($key, $val);
}
文章目录