我今天在这里询问define();
将变量连接到数据库是否明智。我的示例如下:
// Constants For Database
define ("DBAHost", "localhost");
define ("DBAUsername", "xxx");
define ("DBAPassword", "xxx");
define ("DBADB", "xxx");
并处理了连接;
class ClassWork
{
public function AllowDB ($Arg1)
{
if ($Arg1 === 1)
{
$MySQLi = new mysqli(DBAHost, DBAUsername, DBAPassword, DBADB);
return 'Success... ' . mysqli_get_host_info($MySQLi);
}
elseif ($Arg1 !== 1)
{
return 'Wrong Argument Please Consult The Documentation!';
}
}
}
或者更确切地说修改接受数据库连接字符串以通过公共函数推送?