Php 要求你一次不上课吗?

Php 要求你一次不上课吗?,php,Php,下面的脚本用于salt和hash密码,还有另一种方法将其插入数据库 <?php require_once "./Database.php"; class Register { function saltHashPassword($password) { $hashAndSalt = password_hash($password, PASSWORD_BCRYPT); return $hashAndSalt; } functi

下面的脚本用于salt和hash密码,还有另一种方法将其插入数据库

<?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);
    }
}
我不明白为什么它不起作用。我有文件的正确路径。知道我在这里犯了什么错误吗


Database.php和Register.php都位于同一个文件夹“helpers”

中,因为
Register.php
位于
helpers
目录中,如此行所示

require_once "./helpers/Register.php";
并且Database.php不在helpers目录中,如

require_once "./Database.php";
您需要更改
Register.php
中的路径来查找
Database.php
上面的一个目录,如

require_once "../Database.php";

Database.php也在helpers文件夹中,那么它的包含应该是
require\u once.“/helpers/Database.php”你是对的。成功了。是因为调用脚本导入Register.php吗?有没有其他方法可以做到这一点,这样谁调用helper类就无关紧要了?
require_once "./Database.php";
require_once "../Database.php";