Home > Backend Development > PHP Tutorial > 为什么这段代码不能输出

为什么这段代码不能输出

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:15:23
Original
1049 people have browsed it

<code><?php $db = @new mysqli('','','','',3306);
$db->query('SET NAMES utf8');
$m=$db->query('SELECT MAX(id) FROM lab')->fetch_all());
echo $m[0];
?>
</code>
Copy after login
Copy after login

var_dump输出的内容如下:

<code>array(1) { [0]=> array(1) { [0]=> string(1) "1" } } </code>
Copy after login
Copy after login

回复内容:

<code><?php $db = @new mysqli('','','','',3306);
$db->query('SET NAMES utf8');
$m=$db->query('SELECT MAX(id) FROM lab')->fetch_all());
echo $m[0];
?>
</code>
Copy after login
Copy after login

var_dump输出的内容如下:

<code>array(1) { [0]=> array(1) { [0]=> string(1) "1" } } </code>
Copy after login
Copy after login

数组用echo打印出来会报错

数组只能打印,不能echo

print_r();

那是二维数组

把echo $m[0] 改成print_r($m[0]);

理解错误信息,找出错误

Related labels:
php
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template