Google help on software/programming And Windows Tricks: Enable Any Extension in php On runtime

helponsoftware

Tuesday 8 October 2013

Enable Any Extension in php On runtime

When we are using PHPMAILER for email service we found error that "ssl is not enable " So here some code so that u can enable it on runtime

<?php
// Example loading an extension based on OS
if (!extension_loaded('openssl')) {
    if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
        dl('php_openssl.dll');
    } else {
        dl('openssl.so');
    }
}

// Or, the PHP_SHLIB_SUFFIX constant is available as of PHP 4.3.0
if (!extension_loaded('openssl')) {
    $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
    dl($prefix . 'openssl.' . PHP_SHLIB_SUFFIX);
}
?>
For looking that it enable or not........................
<?php
if (extension_loaded('openssl')) {
echo 'openssl extension is loaded and everything is fine!';
}
else {
echo 'Where is the openssl library?';
exit();
}
?>

No comments:

Post a Comment