First thing to do when you can no longer create the DOM

DOMerror

photo credit: ilConte via photopin cc

Good evening, this is Bono.

One day I looked at a web service I had previously created for the first time in a while and found that it had stopped in the middle of the screen.

It did not throw any errors or logs, so I used var_dump and echo to locate the anomaly.

Apparently, it seems to stop at the time of DOM creation.

What to do then.

phenomenon

The process stopped at the second line of the following code. The screen went blank.

After reading a file with file_get_cntents, it may not be able to create the DOM? I expect so.

[crayon] $res=@file_get_contents($query);
$dom=@DOMDocument::loadHTML($res);
$xml=simplexml_import_dom($dom);
$result['img']=$xml- >xpath("//image1");
$result['title']=$xml- >xpath("//title");
[/crayon]

approach

First, re-install anything suspicious.

We have re-installed software that may be related to the DOM. Specifically, the following three.

[crayon] sudo yum update
sudo yum install php-xml
sudo yum install php-devel
[/crayon]

Add extention

This did not fix it, so I googled and added the following code to the last line of /etc/php.ini.

[crayon] extention=dom.so
[/crayon]

Restart apache

Finally, I solved the problem by restarting apache with the following! Good.

[crayon] sudo service httpd restart
[/crayon]