I am new to php OOP and I need some help fixing the following error.
PHP Strict Standards: Only variables should be passed by reference in /home/XXX/public_html/h1.com/includes/Article.class.php on line 30
Here is the code of 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;
I am using PHP5.5