1.get_object_vars($obj) 获取对象$obj的属性数组
2.类和对象
<?php // 类和对象 echo "类和对象" . " "; class Car{ var $color; // 构造方法 /* function Car($color="black", $speed=200.0){ $this->color = $color; $this->speed = $speed; } */ // PHP7之后使用以下方式的构造方法 function __construct($color="black", $speed=200.0){ $this->color = $color; $this->speed = $speed; } // 汽车颜色 function what_color(){ return $this->color; } } class Person{ public $name = "keen"; public $age = 24; public $birth; } // 查看实例对象的属性和值 function print_vars($obj){ // get_object_vars($obj) 获取对象$obj的属性数组 foreach(get_object_vars($obj) as $prop => $val){ echo " $prop = $val "; } } // 实例化对象 $myCar = new Car("white"); // 显示对象的属性和值 print_vars($myCar); $me = new Person(); print_r(get_object_vars($me)); ?>
输出:
3.mysql 启动命令
mysql -u root -p // 然后输入密码
拓展:
http://blog.qiji.tech/archives/132
https://www.zybuluo.com/xile/note/426413