Mosty Amine Mosty Amine - 4 months ago 44
Linux Question

PHP DomDocument class doesn't exist

I was trying to use the class

DomDocument
in my php code on redhat linux server, but when I have tried the following code:

echo "class_exists(\"DomDocument\") = ".(class_exists("DomDocument")?" EXISTS ":" NOT EXISTS ")."<br>";


it prints:

class_exists("DomDocument") = NOT EXISTS


after a small search I found that the extension
php-xml
should be installed, but the class still not exist, and the following is a snippet from
php -i
result:

dom

DOM/XML => enabled
DOM/XML API Version => 20031129
libxml Version => 2.6.26
HTML Support => enabled
XPath Support => enabled
XPointer Support => enabled
Schema Support => enabled
RelaxNG Support => enabled


What is still missing to make this
DomDocument
class work?

Answer

Could you check your php.ini and see if it contains the extension=dom.so line?

Also both libxml and DOM has to be enabled but they are by default so that shouldn't be a problem if you haven't messed with the ini before and your php -i confirms that.