Null for PHP

Source: Internet
Author: User
Why run the code without reporting warning or notice

$data = null;var_dump($data['name']);

Results:

null

Reply content:

Why run the code without reporting warning or notice

$data = null;var_dump($data['name']);

Results:

null

This is a very interesting question, check the information, php.net on the people raised

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

In the back of the page link to see the bird brother @laruence, I think it is best to answer this question, it is him.

$arr = false;var_dump($arr['foo']['bar']['baz']); // NULL

PHP Manual for the original problem:


  
   

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.

This, in my point of view, should is 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 have not been
Defined is the same as accessing any other undefined Variable:an
E_notice-level error message would be issued, and the result would be
NULL. "

Do you check the configuration of the php.ini or add error_reporting (-1) before the output?

Up up.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.