abstract:getmdoleobj = $mdole;
依赖注入两种方式,一种普通方法传参。一种构造方法传
include 'mdole.php';
class Coler
{
public $getmdoleobj = '';
public function __construct(Mdole $mdole)
{
$this->getmdoleobj = $mdole;
var_dump($this->getmdoleobj);
}
public function add()
{
include "viiw.php";
}
public function add_do()
{
$name = $_POST['username'];
$password = $_POST['password'];
$this->getmdoleobj->aaa($name,$password);
}
}
$Colerobj = new Coler($mdole);
$r = isset($_GET['r'])?$_GET['r']:'index';
$Colerobj->$r();
?>
Correcting teacher:查无此人Correction time:2019-04-30 09:16:11
Teacher's summary:完成的不错。sql语句组装,尽量用单引号,加连接符。不要在双引号里使用变量。继续加油。