Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/284.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP XMLReader-访问元素常量但获取T_PAAMAYIM_NEKUDOTAYIM错误_Php_Xmlreader_Libxml2_Parse Error - Fatal编程技术网

PHP XMLReader-访问元素常量但获取T_PAAMAYIM_NEKUDOTAYIM错误

PHP XMLReader-访问元素常量但获取T_PAAMAYIM_NEKUDOTAYIM错误,php,xmlreader,libxml2,parse-error,Php,Xmlreader,Libxml2,Parse Error,有一台服务器正在运行:PHP5.2.17,libxml2.7.8,启用了XMLReader 问题是,当我尝试$xmlReader::ELEMENT时,它抱怨T_PAAMAYIM_NEKUDOTAYIM的解析错误 是否存在引入此行为的特定版本?由于它似乎在我的离线5.3.6服务器上运行良好 $xmlReader = new XMLReader; if (!$xmlReader->open('file.xml', null, 1<<19)){ thr

有一台服务器正在运行:PHP5.2.17,libxml2.7.8,启用了XMLReader

问题是,当我尝试$xmlReader::ELEMENT时,它抱怨T_PAAMAYIM_NEKUDOTAYIM的解析错误

是否存在引入此行为的特定版本?由于它似乎在我的离线5.3.6服务器上运行良好

    $xmlReader = new XMLReader;
    if (!$xmlReader->open('file.xml', null, 1<<19)){
        throw new Exception('Unable to read file',1);
    }

    # Go down to WEBRESOURCES node level
    while ($xmlReader::ELEMENT){ // This is what it throws the parse error for
        if ($xmlReader->name == "blahblah"){
            break;
        }
        $xmlReader->read();
    }
$xmlReader=新的xmlReader;
如果(!$xmlReader->open('file.xml',null,1read();
}

谢谢,Dom使用类的名称而不是实例。
XMLReader::ELEMENT

我认为您的
while
-循环应该是这样的

while ($xmlReader->nodeType == XMLReader::ELEMENT) { 
    if ($xmlReader->name == "blahblah"){
        break;
    }
    $xmlReader->read();
}

谢谢,这解决了问题。我四处看了看,似乎我所尝试的只是>5.3。有什么地方我可以读懂这个吗?谢谢:)@Dominic