18

我正在本地主機上運行php版本5.4.16,而我正在開發我的網站。我想使用password_hash(),但我不斷收到此錯誤:調用未定義的函數password_hash()

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

爲什麼會發生這種情況?

謝謝!

+5

這幫了我!不知道爲什麼這個問題是關閉的,但我有同樣的問題。感謝問! – Supuhstar

回答

27

password_*方法僅可作爲PHP 5.5:

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

看看這個庫,提供前向兼容性:

https://github.com/ircmaxell/password_compat

你可以用它來可以訪問新的password_*方法,直到您能夠運行PHP 5.5。

+1

舊版本的PHP有什麼替代方案?舊版本的 – Doug

+0

使用crypt()http://php.net/manual/en/function.crypt.php您可以將crypt_hash與crypt一起使用的散列 – astroanu