参见英文答案 > Call to undefined function password_hash() in PHP 5.4 1个
我使用安装了PHP 5.5的XAMPP开发了我的网站.我只是意识到我的主机只有php 5.4(还不能更新到5.5).我的问题是我不能使用新的PHP 5.5 password_hash()功能.是否有一个等效的方法用于PHP 5.4的哈希哈希?
有没有办法让这个等效的代码(下面)在PHP 5.4中工作?
$options = [
'salt' => uniqid(mt_rand(), true),
'cost' => 12
];
$hash = password_hash($mypassword, PASSWORD_DEFAULT, $options);
解决方法:
使用password_compat.它是一个向后兼容的库,可以在旧版本的PHP(5.3.7)中模拟password_hash()
.