2009-08-03 20 views
0

我收到以下奇怪的錯誤。獲取我無法弄清楚的「使用未定義常量」錯誤

  • 意外的PHP錯誤[未定義常數s的使用 - 假設的']嚴重性[E_NOTICE]在[C:\ Documents和Settings \ yepthatsme \我的文檔\開發\ nicnames \主\資源\包括\名稱.inc.php線180]

它指的是該生產線具有:

 $types = nicnames_config::$resourcetypes; 

nicnames_config :: $ resourcetypes是一個數組。我不知道這裏談到的是來自哪裏,我開始認爲它可能是一個PHP錯誤,但也許我錯過了一些東西。我應該在哪裏看?

我正在使用SimpleTest進行測試,並且在特定測試期間發生此錯誤。

如果你有興趣,這裏是在上下文中該行:

function getstrings() 
    // returns array of strings suitable for human-readable rendering of this 
    // piece of informtion. Contains such fields as 'title', 'subtitle', 
    // 'pre-qualifier', 'post-qualifier', 'comment', etc 
{ 
    $types = nicnames_config::$resourcetypes; // line 180 

    $type = isset($types['name_type'][$this->type]) ? 
     $types['name_type'][$this->type] : $this->type; 
    $givens = $this->givennames == '' ? null : $this->givennames; 
    return array(
     'title' => $this->surnamefirst ? ($this->surname . ',') : $givens, 
     'subtitle' => $this->surnamefirst ? $givens : $this->surname, 
     'pre-qualifier' => $type, 
     'post-qualifier' => $this->title == '' ? null : ('(' . $this->title . ')'), 
    ) + $this->getcommonstrings(); 
} 

編輯:問題是現在解決了,看到我自己的答案。

+0

whats class nicnames_config {}是什麼樣的? – scott 2009-08-03 07:12:39

回答

2

PHP錯誤消息得到了錯誤的位置錯誤 - 我最終在一個完全不同的源文件的某個行的末尾發現了一個流浪的字母's' - 其中nicnames_config類和這個靜態成員,已被定義。

看起來,當使用靜態成員變量時,變量值不是在聲明該類時指定的,而是在變量首次引用時指定(猜測這是一個不錯的優化),但是如果賦值時出錯PHP獲取錯誤的位置錯誤。

相關問題