我有這樣的代碼:HHVM DomDocument loadHTMLFile()不起作用。 BUG?
$doc = new DOMDocument();
$doc->validateOnParse = true;
$doc->formatOutput = true;
$doc->loadHTMLFile($file);
$raw = $doc->saveHTML();
當我做了var_dump($raw)
它會顯示string(1) " "
。有些東西顯然是錯誤的。
一個var_dump($doc)
輸出
object(DOMDocument)#5228 (35) {
["recover"]=>
bool(false)
["documentURI"]=>
NULL
["strictErrorChecking"]=>
bool(true)
["xmlStandalone"]=>
bool(true)
["standalone"]=>
bool(true)
["attributes"]=>
NULL
["nodeValue"]=>
NULL
["resolveExternals"]=>
bool(false)
["childNodes"]=>
string(22) "(object value omitted)"
["previousSibling"]=>
NULL
["nodeName"]=>
string(9) "#document"
["xmlVersion"]=>
string(3) "1.0"
["lastChild"]=>
NULL
["nodeType"]=>
int(9)
["formatOutput"]=>
bool(true)
["firstChild"]=>
NULL
["parentNode"]=>
NULL
["ownerDocument"]=>
NULL
["config"]=>
NULL
["prefix"]=>
string(0) ""
["implementation"]=>
string(22) "(object value omitted)"
["preserveWhiteSpace"]=>
bool(true)
["documentElement"]=>
NULL
["namespaceURI"]=>
NULL
["baseURI"]=>
NULL
["substituteEntities"]=>
bool(false)
["textContent"]=>
string(0) ""
["nextSibling"]=>
NULL
["doctype"]=>
NULL
["validateOnParse"]=>
bool(true)
["version"]=>
string(3) "1.0"
["actualEncoding"]=>
NULL
["encoding"]=>
NULL
["localName"]=>
NULL
["xmlEncoding"]=>
NULL
}
可能是什麼問題?
#更新:
錯誤是loadHTMLFile()
。它返回一個FALSE。但爲什麼?該文件的路徑是正確的。
如果我不是這樣做:
$doc->loadHTML(file_get_contents($file));
它工作得很好。這是HHVM的錯誤嗎?
這是否不HHVM工作的事情在常規PHP做工精細環境? – halfer
我不明白爲什麼它不應該。 – Michael
我認爲你已經錯過了我所做的一點。如果它在普通的PHP中工作,但不在HHVM中,那麼它可能是HHVM的一個錯誤,或者是一種已知的不同行爲。另一方面,如果它在PHP中不起作用,那麼也許你做錯了什麼。長話短說:值得在普通的PHP環境中嘗試。 – halfer