Correction status:qualified
Teacher's comments:
类就是对象的模版,对象是类的一个实例
举例:汽车就是一个类,有以下属性:名称、车型、轴距、排量、长宽高。
对象:具体的车型:丰田霸道:车型SUV,轴距2790,排量3.5,长宽高[5,2,2]
<?php class Car{ private $name; private $type; private $zhouju; private $pailiang; private $ckg=[]; public function __construct($name,$type,$zhouju,$pailiang,array $ckg) { $this->name=$name; $this->type=$type; $this->zhouju=$zhouju; $this->pailiang=$pailiang; $this->ckg=$ckg; } public function __get($name) { return $this->$name; } public function __set($name, $value) { return $this->$name=$value; } } $prado = new Car('prado','suv',2790,3.5,[5,2,2]); echo $prado->name,'<br>'; echo $prado->type,'<br>'; echo $prado->zhouju,'<br>'; $prado->zhouju=3000; echo $prado->zhouju,'<hr>';
点击 "运行实例" 按钮查看在线实例
mysql增删改查语句:
insert into staff (name,salary) values ('xumeng',10000); delete from staff where name='xumeng'; update staff set salary=11111 where id='1'; select * from staff ;
点击 "运行实例" 按钮查看在线实例
数组配置连接参数:
<?php $db=[ 'host'=>'127.0.0.1', 'user'=>'root', 'pass'=>'root', 'name'=>'php', 'charset'=>'utf8', ];
点击 "运行实例" 按钮查看在线实例
连接与检测:
<?php require 'mysqli/作业config.php'; //配置连接参数 error_reporting(E_ALL ^E_WARNING); //warning级错误不显示 $mysqli =new mysqli($db['host'],$db['user'],$db['pass']); //数据传入连接参数 if ($mysqli->connect_errno){ die('连接错误'.$mysqli->connect_errno.':'.$mysqli->connect_error); }else { echo '连接成功', '<hr>'; }
点击 "运行实例" 按钮查看在线实例
手写 mysqli常用属性与方法