PHP DOM loadHTML() method unusual warning -


i had following code works fine on localhost:

$document = new domdocument(); $document->loadhtml($p_result);  $form = $document->getelementsbytagname('form')->item(0);  // code continues using $form variable 

after same code updated on outside server, loadhtml() failed , issued warning.

warning:  domdocument::loadhtml() expects parameter 1 valid path, string given in path/name/to/script.php 

returned null instead of object code pretty gets fatal error.

note contents of $p_result absolutely same on outside server , on localhost.

but why displays kind of warning , why not work?

doesn't loadhtml() expects argument 1 string in first place?

why method expects parameter 1 valid path?

just make clear i'm not calling loadhtmlfile(), i'm calling loadhtml().

thanks.

you're affected one of php bugs. issue present in php 5.6.8 , 5.6.9. have affected php version on server, , bug-free version on localhost.

the bug forbids null characters in html document you're loading, workaround may try remove (actually not needed) characters before further parsing.

$document = new domdocument(); $p_result_without_null_chars = str_replace("\0", '', $p_result) $document->loadhtml($p_result_without_null_chars); 

Comments

Popular posts from this blog

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -