PHP严格标准:引用错误只能传递变量

PHP严格标准:引用错误只能传递变量,php,Php,我是php OOP新手,需要一些帮助来修复以下错误 PHP严格标准:第30行的/home/XXX/public_html/h1.com/includes/Article.class.PHP中只能通过引用传递变量 下面是Article.class.php-->loadByUrl的代码 <?php class Article extends DBEntity { static $table= 'article', $pkey = 'articleID', $db

我是php OOP新手,需要一些帮助来修复以下错误

PHP严格标准:第30行的/home/XXX/public_html/h1.com/includes/Article.class.PHP中只能通过引用传递变量

下面是Article.class.php-->loadByUrl的代码

<?php
    class Article extends DBEntity
    {
        static $table= 'article', $pkey = 'articleID', $db, $fields, $fieldnames;

        static $relations= array(

        );

        function save($model = null)
        {
            if(($article = $this->loadByUrl($this->getUrl())) && $article->articleID != $this- >articleID)
            {
                trigger_error("The URL specified for this article is in conflict with another article.");
                return false;
            }

            return parent::save($model);
        }


        public static function loadByUrl($url, $type = null)
        {
        $url = trim($url);

        $conditions = array("articleURL = '$url'");

        if($type)
        $conditions[] = "articleType = '$type'";

        // Line 30 error
        return array_pop(Article::listAll(new DBEListCriteria(implode(' and ', $conditions), null, new DBEListOffset(1))));
        }

        }

    class DBEListCriteria
    {
        private $condition;

        function __construct($condition = '')
        {
            $this->condition = $condition;
        }

        function __toString()
        {
            if(!empty($this->condition))
                return ("where " . $this->condition);
            return "";
        }

        function getCondition()
        {
            return $this->condition;
        }
    }


    class DBEListOffset
    {
        protected $offset, $limit;

        function __construct($limit = 50, $offset = 0)
        {
            $this->offset = intval($offset);
            $this->limit = intval($limit);
        }

        function __toString()
        {
            if(!empty($this->offset) && !empty($this->limit))
                return " limit {$this->offset}, {$this->limit} ";
            else if(empty($this->offset) && !empty($this->limit))
                return " limit {$this->limit} ";
            else
                return "";
        }
    }
?>

Article::loadByUrl called at initialisation time to get an environment variable into $_ENV[site] array:

if($article = Article::loadByUrl(''))
$_ENV[site]->Article = $article;
array\u pop()
将数组作为引用,您正在传递一个无法引用的函数的返回值。看

只需更改为:

$array = Article::listAll(new DBEListCriteria(implode(' and ', $conditions), null, new DBEListOffset(1)));
return array_pop($array);

但是我想问,为什么不对查询中的行进行排序,并将其限制为1?

也许您还想将引用添加到列表中:可以通过引用传递的内容。(因此,对于类似的问题,这个问题会有一个很好的书签:)