为什么我会
Undefined variable: req
当我在我班级的顶层宣布该物业时:
<?php
namespace Craft;
class Disqus_ApiService extends BaseApplicationComponent
{
private $req = false;
public function init()
{
$d = craft()->plugins->getPlugin('disqus');
$settings = $d->getSettings();
$this->$req = new \DisqusAPI($settings['DISQUS_SECRET_KEY']);
}
public function trends()
{
return $this->req->trends;
}
}
答案 0 :(得分:7)
使用
$this->req
而不是
$this->$req
在
$this->$req = new \DisqusAPI($settings['DISQUS_SECRET_KEY']);