The mcrypt extension was deprecated in PHP 7.1 and removed from PHP core in PHP 7.2. New PHP applications should use Sodium where suitable or OpenSSL for supported cryptographic operations.
The mcrypt installation material below is retained only as historical/migration reference for old PHP environments.
Historical reference: The material below documents older PHP environments where mcrypt was installed separately. It is not a setup guide for current PHP.
Removed from PHP core: mcrypt was deprecated in PHP 7.1 and removed in PHP 7.2. The sections below are historical reference only.
Enabling mcrypt setting inside PHP.INI
Inside your php.ini file search for the line
;extension=php_mcrypt.dll
Change this line to
extension=php_mcrypt.dll
Loading the extension
Inside your php extension directory ( where all other extension dll files are stored) your dll file should be there . like this
If it is not there then you have to install the extension. Go to control panel
Control Panel > Programs > Programs and Features
Uninstall or change a program
Select PHP and go for Change
Checking php installation
We can use phpinfo() function to know the settings of our PHP installation. If mcrypt is available then we will get this while using phpinfo() .
For Linux or LAMP
Add the extension by adding this line.
extension=mcrypt.so
After this you have to restart your web server.
Checking extension status and function
We can use function_exists() to check of mycrypt functions are available or not. Similarly we can check status of extension by using extension_loaded(). Here is a sample code to know the status of mcrypt support in your PHP installation.
<?Phpif(function_exists('mcrypt_create_iv')){
echo "<br>mcrypt_create_iv function support is available ";
}else{
echo "<br>mcrypt_create_iv function support is NOT available ";
}
if (extension_loaded('mcrypt')) {
echo "<br>mcrypt support is loaded ";
}else{
echo "<br>mcrypt support is NOT loaded ";
}
?>
The output of above code will tell about the mrypt support in our PHP installation.
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery,
and web development at plus2net. The tutorials focus on clear explanations, working
examples, and code that readers can test and adapt while learning.