How to check if SimpleXML is installed on my PHP or not?

Does anyone know this? This item is installed by default. But is there an easy way to check if an extension is installed or not?

I check that simplexml_load_string is available to me, but as simplexml is not specified in php.ini

+6
source share
6 answers

There is another way. You can create php page

<?php echo phpinfo(); ?> 

You can see that Simple XML is enabled or disabled here.

+8
source

This works for me ...

 extension_loaded('simplexml') 

Example:

 if (extension_loaded('simplexml')) { echo "all good, extension is installed"; } else{ echo "snip snap! no cigar";} 
+5
source

Use this command on the command line:

php -i | grep -i simplexml

The result should be something like this:

Simplexml

Simplexml support => enabled

+5
source

If you have access to the command line in your field; either use the OS package management system, or run php -m , which should indicate all installed modules that PHP knows about. Any module that has been installed but not registered as an extension in php.ini or elsewhere will not be displayed.

EDIT

It should be noted that running this command will only indicate which extensions are included for the CLI binary / configuration code. This is usually, but it may not always coincide with what included binary / config Apache / FPM

+4
source

One solution that I am using:

 if(class_exists('XMLReader')){ }elseif(function_exists('simplexml_load_file')){ //simplexml available }else{ } 
+1
source
 echo '<pre>'; print_r( get_loaded_extensions()); echo '</pre>'; 

This will show you a list of extensions. Then just use in_array () if you want your application to inform its users that their installation will not run your code.

EDIT In any case, this applies to version 5.2.6 on win32.

0
source

Source: https://habr.com/ru/post/893255/


All Articles