我在名为config.php的脚本中有$ mo_conf变量,我想从另一个脚本mo_model.php中获取它。两者都在不同的目录中。
代码:
的config.php
$mo_conf['user'] = "root";
$mo_conf['password'] = "passwd";
$mo_conf['host'] = "localhost";
$mo_conf['database'] = "itienda";
mo_model.php
class MO_Model extends MO_Object
{
private $con;
static function db_connect()
{
$con = mysqli_connect($mo_conf['host'],$mo_conf['usr'],$mo_conf['password'],$mo_conf['database']);
}
}
运行脚本后,将显示以下通知:
注意:未定义的变量:第59行的C:\ m \ core \ mo_model.php中的$ mo_conf
出了什么问题?
感谢。