php 调用未定义的函数 password_hash()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20955465/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 03:41:56  来源:igfitidea点击:

Call to undefined function password_hash()

phppassword-encryptionpassword-hashphp-password-hashundefined-function

提问by user3162085

I am running php version 5.4.16 on localhost right now, while I am developing my site. I want to use password_hash(), but I keep getting this error:

我现在正在 localhost 上运行 php 版本 5.4.16,同时我正在开发我的网站。我想使用password_hash(),但我不断收到此错误:

Fatal error:Call to undefined function password_hash() in /dir/to/file.phpon line 123

致命错误:在第123行调用/dir/to/file.php 中未定义的函数 password_hash()

Why is this happening?

为什么会这样?

Thanks!

谢谢!

回答by jszobody

The new password_*methods are only available as of PHP 5.5:

password_*方法仅从 PHP 5.5 开始可用:

http://www.php.net/manual/en/function.password-hash.php

http://www.php.net/manual/en/function.password-hash.php

Take a look at this library that provides forward compatibility:

看看这个提供向前兼容性的库:

https://github.com/ircmaxell/password_compat

https://github.com/ircmaxell/password_compat

You can use that to get access to the new password_*methods until you are able to run PHP 5.5.

您可以使用它来访问新password_*方法,直到您能够运行 PHP 5.5。