2011-04-08 9 views
0

我呼籲散列函數在我的代碼一樣(PHP版本5.2.14)調用未定義的函數的散列()在/ var /網絡/網站/問題

$username =hash("sha256",trim($_POST['username'])); 
$password =hash("sha256",trim($_POST['password'])); 

,但我得到了錯誤,如 呼叫到/ var/www/site /中的未定義函數hash()/ 怎麼辦?

+0

哪個php版本? – KingCrunch 2011-04-08 07:42:11

+0

PHP版本..? – 2011-04-08 07:42:12

+0

你有什麼版本的PHP?如果你看一下文檔http://jp.php.net/manual/zh/function.hash.php,你會發現你需要一個PHP 5> = 5.1.2或者pecl模塊.... 。 – RageZ 2011-04-08 07:42:55

回答

4

這意味着它無法找到功能hash()。檢查manual我看到這個:

(PHP 5 >= 5.1.2, PECL hash >= 1.1) 

什麼PHP版本你運行?試試:

<? phpinfo() ?> 

要檢查。如果它低於5.1.2,則沒有hash()函數可用

2

'hash()'是在PHP 5.1.2中引入的,所以有可能您的版本較舊。

2

檢查你的PHP版本,因爲散列函數是僅適用於版本PHP 5> = 5.1.2 PECL散列> = 1.1

0

如果你有一箇舊版本,你仍然可以恢復到SHA1或SHA256功能如下:

$username = sha1(trim($_POST['username'])); 
$password = sha1(trim($_POST['password'])); 

OR

$username = sha256(trim($_POST['username'])); 
$password = sha256(trim($_POST['password'])); 

然而,有大約都在這裏一個很好的理由:SHA1 vs md5 vs SHA256: which to use for a PHP login?

0

如果您的PHP版本> 5.1.2,則啓用散列擴展功能,通過在php.ini配置文件中取消註釋其行並重新啓動web服務器