Reputation: 2362
I was running through a situation when i am unable to find if extension enabled and extension installed. I googled it did not get a direct answer.
I have two questions-
que1-
How to check if an extension is installed ?
que2-
How to check if that extension is installed then is it enabled or not?
I have found bunch of php functions like get_loaded_extensions
, extension_loaded
, function_exixts
which i found has been used, but what is the exact difference between using each one of them?
Any help would be appreciated :) Thanks
Upvotes: 1
Views: 2145
Reputation: 140
To check whether an extension is installed you should use the get_loaded_extensions()
to get a list of all extensions that are installed. In order to check whether a specific extension is installed you could use extension_loaded
.
To check whether functions exist or not (function that come with the extension for example) you should use function_exixts
.
Another possibility to check whether an extension is installed is by looking at your phpinfo()
and browse for the extension you are looking for.
At the command line you could run php -m
and then to get you all the modules and then php -i
to see more about the configuration of it.
When you know the extension is installed you could enable it by looking at the php.ini file and search for extension=extensionname.so
(when using Unix). when using Windows look for extension=extensionname.dll
. When you cannot find this you will need to add it to the list with others that do exist.
Hope this helps.
Upvotes: 1