【发布时间】:2018-12-30 19:43:56
【问题描述】:
我对下面的代码有问题,所以我创建了一个数据库连接并在 CMD 中运行它似乎工作正常,但我不是 100% 如何测试它?有人可以指出是否可以,我还是 PHP 的新手
<?php
class databaseConnection
{
private $host;
private $databasename;
private $username;
private $password;
public $mysqli;
//forcing the data to be given to the object (using the constructor)
public function __construct()
{
$this->databaseConnect();
}
private function databaseConnect()
{
$this->host = 'localhost';
$this->username = '$$$$$';
$this->password = '$$$$$';
$this->databasename = '$$$$$$$';
$this->mysqli = new mysqli($this->host, $this->username, $this->password, $this->databasename);
return $this->mysqli;
echo('Connection Succeeded');
}
}
【问题讨论】:
-
尝试在单独的文件中获取类并使用 select 语句?