php的null

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
リリース: 2016-06-06 20:38:46
オリジナル
1064 人が閲覧しました

为什么运行一下代码不报warning或者notice

<code>$data = null;

var_dump($data['name']);
</code>
ログイン後にコピー
ログイン後にコピー

结果:

<code>null
</code>
ログイン後にコピー
ログイン後にコピー

回复内容:

为什么运行一下代码不报warning或者notice

<code>$data = null;

var_dump($data['name']);
</code>
ログイン後にコピー
ログイン後にコピー

结果:

<code>null
</code>
ログイン後にコピー
ログイン後にコピー

这是一个很有意思的问题, 查了查资料, php.net上有人提出过

https://bugs.php.net/bug.php?id=68110
https://bugs.php.net/bug.php?id=54556

在后面的那页链接里看到了鸟哥@Laruence, 我想能最好深入解答这个问题, 就是他了.

<code>$arr = false;
var_dump($arr['foo']['bar']['baz']); // NULL
</code>
ログイン後にコピー

php手册上问题原文:

<code><?php $a['a'] = null;
$a['b'] = array();

echo $a['a']['non-existent']; // DOES NOT throw an E_NOTICE error as expected.

echo $a['b']['non-existent']; // throws an E_NOTICE as expected
?>
</code>
ログイン後にコピー

I added this bug to bugs.php.net
(https://bugs.php.net/bug.php?id=68110) however I made tests with
php4, 5.4 and 5.5 versions and all behave the same way.

This, in my point of view, should be cast to an array type and throw
the same error.

This is, according to the documentation on this page, wrong.

From doc: "Note: Attempting to access an array key which has not been
defined is the same as accessing any other undefined variable: an
E_NOTICE-level error message will be issued, and the result will be
NULL."

你检查下php.ini的配置呢 或者在输出前加error_reporting(-1);试下呢

Up up..

関連ラベル:
php
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
PHP 拡張子 intl
から 1970-01-01 08:00:00
0
0
0
phpのデータ取得?
から 1970-01-01 08:00:00
0
0
0
PHP GET エラー レポート
から 1970-01-01 08:00:00
0
0
0
phpを上手に学ぶ方法
から 1970-01-01 08:00:00
0
0
0
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート