I want to check the geo_ip
extension in php.ini via PHP CODE
But i dont know, how to check ?
Is any solutions are available to check the extensions are enabled or not in php.ini.
Thanks in Advance.
I want to check the geo_ip
extension in php.ini via PHP CODE
But i dont know, how to check ?
Is any solutions are available to check the extensions are enabled or not in php.ini.
Thanks in Advance.
You need use the extension_loaded function of SPL
$sExtensionName = 'geoip';
if (!extension_loaded($sExtensionName)) {
exit("Error extension {$sExtensionName} not loaded");
}
Reference function.extension-loaded.php
I am not sure what do you mean by via PHP CODE.
If you are trying to check enabled PHP extension in your web server without using Terminal/SSH or any commands, then you can try the described way to check using your browser.
Create a PHP file(file with .php extension). for example, checkEnabledExtension.php
Now edit the file and add the following codes and save it:
<?php
$extensionName = "mysqli"; // replace mysqli by the extension name your want to check. for example: $extensionName = "geoip"; I am not sure about the name of the geo_ip extension.
echo $extensionName;
if(extension_loaded($extensionName)) { // check extension_loaded() in PHP manual for details
echo ": is Enabled."; // if the extension is enabled this block will run
} else {
echo ": is NOT Enabled."; // this block will run if the extension is not enabled
}
?>
Now upload the file to your web root directory. For example: if your domain name is example.com then upload it to web root/public_html of the example.com
Now in your browser go to domain.com/checkEnabledExtension.php
That is it. You will see if the extension is enabled or not.
To check a list of all enabled extension:
use this PHP codes in checkEnabledExtension.php
file to get the list of all enabled php extensions instead of checking a single. Use the same procedures above just use these codes:
<?php
print "<pre>"; print_r(get_loaded_extensions()); print "</pre>"; // this will print a list of all enabled PHP extension
?>
BEST OF LUCK