嗨我在与$this
没有在我的代码中传递的一个奇怪的问题,我希望 有人能帮助我,结构如下:PHP属性存在于类
Class
{
protected _foo = '';
.........
self::_setSessionsToProperties('_foo', array('access_token','instance_url'));
..........
protected static function _setSessionsToProperties($property, $setter)
{
self::_validateApprovedSessions($setter);
if (isset($this->$property) || property_exists($this, $property))
{
foreach ($setter as $set) { $this->$property->$set; }
}
return $this;
}
Undefined variable: this
为了得到这个工作,虽然我不得不通过$this
作为参数字符串,其中 似乎非常反直觉?
self::_setSessionsToProperties($this, '_foo', array('access_token','instance_url'));
..........
protected static function _setSessionsToProperties($this, $property, $setter)
这是怎么回事?
您不能在静态函数中使用'$ this'。 – 2013-02-21 20:41:02