Php 得到一个;未定义常数的使用“;我无法理解的错误
我得到以下奇怪的错误Php 得到一个;未定义常数的使用“;我无法理解的错误,php,static,Php,Static,我得到以下奇怪的错误 [C:\Documents and Settings\yepthatsme\My Documents\Dev\nicnames\main\resources\includes\name.inc.PHP第180行]中出现意外的PHP错误[使用未定义的常量s-假定的's']严重性[E_NOTICE] 它所指的行有: $types = nicnames_config::$resourcetypes; nicnames\u config::$resourcet
- [C:\Documents and Settings\yepthatsme\My Documents\Dev\nicnames\main\resources\includes\name.inc.PHP第180行]中出现意外的PHP错误[使用未定义的常量s-假定的's']严重性[E_NOTICE]
$types = nicnames_config::$resourcetypes;
nicnames\u 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();
}
编辑:问题现在解决了,请看我自己的答案。PHP错误消息错误地获取了错误位置-我最终在一个完全不同的源文件中的某行末尾找到了一个零散的字母“s”-定义了nicnames\u config类和这个静态成员的文件
似乎在使用静态成员变量时,变量值不是在声明类时分配的,而是在首次引用变量时分配的(猜测这是一个不错的优化),但是如果分配值时出错,PHP会错误地获取错误的位置。类名称\u config{}看起来像什么?