Home » Php » mysql – How to Test Whether SimpleXML is installed on my PHP or not?

mysql – How to Test Whether SimpleXML is installed on my PHP or not?

Posted by: admin July 12, 2020 Leave a comment


Anyone knows that? That thing is installed by default. But is there an easy way to check whether an extension is installed or not?

I check that simplexml_load_string is available to me but how do simplexml is not listed on php.ini

How to&Answers:

There is another way also. You can create a php page

     echo phpinfo();

You can see Simple XML enabled or disabled here.


This works for me…



if (extension_loaded('simplexml')) {

    echo "all good, extension is installed";

} else{ echo "snip snap! no cigar";}    


Use this command on the commandline:

php -i | grep -i simplexml

The result should be something like this:


Simplexml support => enabled


If you have command line access on your box;
either use your OS’s package management system, or run php -m which should list all installed modules which PHP is aware of.
Any module which has been installed but is not registered as extension in php.ini or anywhere else will not show up.


It should be noted that running this command will only tell you what extensions are enabled for the CLI binary/config of PHP. This generally is, but may not always be, match up with what the Apache/FPM binary/config has enabled


One solution i use :


//simplexml available



echo '<pre>';
print_r( get_loaded_extensions());
echo '</pre>';

That will show you a list of extensions. Then just use in_array() if you want your application to smartly tell your users that their setup will not run your code.

EDIT This is the case on 5.2.6 on win32 anyway.