遍历MYSQLI对象怎么没有结果
$conn = new mysqli('localhost','root','625332','zly',3306);
var_dump($conn);
echo "<br/>-------------------------<br/>";
foreach($conn as $key => $value) {
print "$key => $value<br/>";
}
输出结束:
object(mysqli)#1 (19) { ["affected_rows"]=> int(0) ["client_info"]=> string(79) "mysqlnd 5.0.11-dev - 20120503 - $Id: 76b08b24596e12d4553bd41fc93cccd5bac2fe7a $" ["client_version"]=> int(50011) ["connect_errno"]=> int(0) ["connect_error"]=> NULL ["errno"]=> int(0) ["error"]=> string(0) "" ["error_list"]=> array(0) { } ["field_count"]=> int(0) ["host_info"]=> string(20) "localhost via TCP/IP" ["info"]=> NULL ["insert_id"]=> int(0) ["server_info"]=> string(10) "5.7.19-log" ["server_version"]=> int(50719) ["stat"]=> string(137) "Uptime: 233310 Threads: 1 Questions: 275 Slow queries: 0 Opens: 133 Flush tables: 1 Open tables: 126 Queries per second avg: 0.001" ["sqlstate"]=> string(5) "00000" ["protocol_version"]=> int(10) ["thread_id"]=> int(65) ["warning_count"]=> int(0) }
-------------------------
affected_rows =>
client_info =>
client_version =>
connect_errno =>
connect_error =>
errno =>
error =>
error_list =>
field_count =>
host_info =>
info =>
insert_id =>
server_info =>
server_version =>
stat =>
sqlstate =>
protocol_version =>
thread_id =>
warning_count =>
想问一下用foreach遍历出来的为什么只有key没有value呢?
用var_dump又可以显示出来。