嘿伙计们,我有一个奇怪的问题,$this
我的代码没有被传递,我希望有人可以帮助我,结构如下:
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)
这里发生了什么??