以下腳本用於salt和散列密碼,並有另一種方法將其插入數據庫。require_once不能用於課堂?
<?php
require_once "./Database.php";
class Register {
function saltHashPassword($password) {
$hashAndSalt = password_hash($password, PASSWORD_BCRYPT);
return $hashAndSalt;
}
function insertNewMember($username, $password) {
$database = new Database();
$database->insertNewMember($username, $password);
}
}
的方法是通過這個文件
<?php
require_once "./helpers/Register.php";
$regiter = new Register();
$saltAndHashedPassword = $regiter->saltHashPassword("dfgsdfg");
$regiter->insertNewMember("testuser", $saltAndHashedPassword);
?>
稱爲當我運行該腳本,我得到以下
PHP Warning: require_once(./Database.php): failed to open stream: No such file or directory in /var/www/mate8/helpers/Register.php on line 3
PHP Fatal error: require_once(): Failed opening required './Database.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/mate8/helpers/Register.php on line 3
我不明白爲什麼它不工作。我有正確的文件路徑。任何想法我在這裏犯了什麼錯誤?
兩個database.php文件和Register.php是在同一文件夾「幫手」
文件權限? –