简体   繁体   English

面向PHP对象的“严格标准:仅变量应通过引用传递给”

[英]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.

相关问题 烦人的PHP错误:“严格的标准:只有变量应该通过引用传递” - Annoying PHP error: “Strict Standards: Only variables should be passed by reference in” 严格标准:只应在functions.php中通过引用传递变量 - Strict Standards: Only variables should be passed by reference in functions.php PHP严格标准:在wordpress函数中,只能通过引用传递变量 - PHP Strict Standards: Only variables should be passed by reference in on wordpress function 严格的标准:只能通过引用传递变量PHP购物车 - Strict Standards: Only variables should be passed by reference PHP Shopping Cart 严格标准:只应通过引用传递变量 - php错误 - Strict Standards: Only variables should be passed by reference - php error PHP 严格标准:在 .lib 中只应通过引用传递变量 - PHP Strict Standards: Only variables should be passed by reference in .lib PHP严格标准:只有变量应通过引用传递给 - PHP Strict Standards: Only variables should be passed by reference in 严格标准:只有变量应通过引用传递给 - Strict Standards: Only variables should be passed by reference in 严格的标准:只有变量应该通过引用传递 - Strict Standards: Only variables should be passed by reference 严格标准:仅变量应通过引用传递 - Strict Standards: Only variables should be passed by reference
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM