Home  >  Article  >  Backend Development  >  is_array detects an array and returns false

is_array detects an array and returns false

WBOY
WBOYOriginal
2016-08-08 09:06:53988browse

<code>echo $res;
var_dump($res);
var_dump(is_array(res));</code>

$res is the result of the database query. If there is a result, it returns an array. If there is no result, it returns false. But now even if $res is an array, it is false. Below is the display result.

<code>Array
array(3) { ["ID"]=> string(1) "1" ["USERNAME"]=> string(4) "root" ["NICKNAME"]=> string(17) "复仇者联盟~~" } 
bool(false)</code>

Is it because of the php configuration?

Reply content:

<code>echo $res;
var_dump($res);
var_dump(is_array(res));</code>

$res is the result of the database query. If there is a result, it returns an array. If there is no result, it returns false. But now even if $res is an array, it is false. Below is the display result.

<code>Array
array(3) { ["ID"]=> string(1) "1" ["USERNAME"]=> string(4) "root" ["NICKNAME"]=> string(17) "复仇者联盟~~" } 
bool(false)</code>

Is it because of the php configuration?

var_dump(is_array($res));
You missed $

Feeling sorry, on the importance of syntax highlighting

Haha, this kind of little mistake is often made

Statement:
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