访问未声明的静态属性

时间:2017-08-21 13:39:14

标签: php static-methods

我的代码段:

public static function saveEntryView($content, $conf, $m_name, $m_firstname, $m_street, $m_zipcity, $m_phone, $m_email, $m_rooms, $m_etage, $m_wohnberechtigungsschein, $m_member, $m_mieter, $m_termin, $m_size, $m_msg ) 
{


    self::$conf['template'] = '/home/www/p422082/html/typo3/fileadmin/wgkw/templates/wgkwcontactform.html';

我之前:

$this->$conf['template'] = '/home/www/p422082/html/typo3/fileadmin/wgkw/templates/wgkwcontactform.html';

这基本上说我在静态函数中调用非静态对象并给了我这个错误(完全公平):

Using $this when not in object context 

并引导我关注主题PHP Fatal error: Using $this when not in object context 在那里我发现它可以改为:

self::$conf['template'] = '/home/www/p422082/html/typo3/fileadmin/wgkw/templates/wgkwcontactform.html';

但它让我可以访问未声明的静态属性:$ conf error。

这让我想到了这个主题:Access to undeclared static property $this

基本上回到问题已经开始的开始,这让我很困惑。感谢任何帮助/提示。

0 个答案:

没有答案