<?php /** * Created by PhpStorm. * User: lenovo * Date: 2016/10/25 * Time: 13:14 */ class ConnDB { //成员变量 var $host; var $user; var $pwd; var $DBtype; var $DBname; var $conn; //成员函数 function ConnDB($host, $user, $pwd, $DBtype, $DBname) { $this->host = $host; $this->user = $user; $this->pwd = $pwd; $this->DBname = $DBtype; $this->DBtype = $DBtype; } function getconnID() { echo "<br>" . "登录服务器用户名:" . $this->user; echo "<br>" . "登录服务器密码:" . $this->pwd; } function closeconnID() { echo "<br>" . "关闭服务器"; } } //创建对象 $connobj =new ConnDB("localhost","root","root","mySQL","zuzi"); echo "<br>"."服务器".$connobj->host; echo "<br>"."数据库类型".$connobj->DBtype; $connobj->getconnID(); $connobj->closeconnID(); ?>
慕粉3149663
Tobey_滔