$stmt = $dbh->prepare("SELECT thing FROM table WHERE color = :color");
$stmt->bindParam(':color', $someClass->getColor());
$stmt->execute();
產生這樣的:
運行時通知
只有變量應該由 參考
雖然它仍然執行傳遞。
此:
$stmt = $dbh->prepare("SELECT thing FROM table WHERE color = :color");
$tempColor = $someClass->getColor();
$stmt->bindParam(':color',$tempColor);
$stmt->execute();
運行毫無怨言。
我不明白區別?