php的null

php中文网
发布: 2016-06-06 20:38:46
原创
1100人浏览过

为什么运行一下代码不报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上有人提出过

立即学习PHP免费学习笔记(深入)”;

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

zyupload四种不同的上传PHP版
zyupload四种不同的上传PHP版

zyupload四种不同的上传PHP版

zyupload四种不同的上传PHP版 110
查看详情 zyupload四种不同的上传PHP版

在后面的那页链接里看到了鸟哥@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
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号