[英]PHP Object Oriented “Strict standards: Only variables should be passed by reference in”
So I have read too many of this questions already, and have also read PHP: Passing by reference manual and still cannot figure out why I am seeing this. 因此,我已经阅读了太多此类问题,并且还阅读了PHP:通过参考手册传递 ,仍然无法弄清为什么我会看到此问题。
So I have a PHP Class
所以我有一个
PHP Class
class ProfileTranslator extends EntityTranslator {
public function getProfile($identifier) {
try {
$stmt = $this->dbConn->prepare("CALL get_profile(?)");
$stmt->bindParam(1, $identifier, \PDO::PARAM_STR);
$stmt->execute();
$rows = $stmt->fetchAll(\PDO::FETCH_ASSOC);
unset($stmt);
$count = count($rows);
if ($count == 1) {
$row = $rows[0];
$profile = new entity\Profile();
$this->assignProfileData($row, $profile);
// more stuff below...
}
private function assignProfileData($row, $profile) {
$profile->setProfileId($row['profileid']);
// do some more ->setXYZ's()
$this->getAccount($profile); // GETTING ERROR HERE (THIS IS LINE 119)
}
private function getAccount($profile) {
// get the account stuff here
}
}
Error: 错误:
( ! ) Strict standards: Only variables should be passed by reference in ProfileTranslator.php on line 119
(!)严格的标准:仅在第119行的ProfileTranslator.php中通过引用传递变量
What is the problem with this code? 此代码有什么问题? Isn't
$profile
a variable? $profile
不是变量吗?
$profile
is a variable, but it countains an object , one that's accessed by $profile->setProfileId
$profile
是一个变量,但是它包含一个对象 ,该对象可以通过$profile->setProfileId
访问
$profile = new entity\Profile();
which by strict standard should not be passed by reference, as in a function: 按照严格的标准,它不应通过引用传递,例如在函数中:
$this->getAccount($profile);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.