Summary of Php:empty,isset,is_null,array (0), array (), Array (""), 0, "0", "", "null", NULL

Source: Internet
Author: User

Use the following procedure to detect

$a =0;if (empty ($a)) {echo "yes|";} Else{echo "no|";} if (Isset ($a)) {echo "yes|";} Else{echo "no|";} if (Is_null ($a)) {echo "yes|";} Else{echo "no|";} if ($a) {echo "yes|";} else {echo "no|";}

So the result of a $ A difference is as follows



Summarize:

The case of empty

The value of the 1 variable is empty $var = "";

The value of the 2 variable is a string of 0 or the number 0 $var = 0; or $var = "0″

The value of the 3 variable is flase $var = flase;

4 Null is empty

5 Empty array $arr =array ();

The 6 variable only defines $var that are not assigned value;

the situation of Isset

See if a variable is already set and not empty (determine if a variable is set and are NOT NULL)

Is_null

Determine null

Judging whether it is false

The value of the 1 variable is empty $var = "";

The value of the 2 variable is a string of 0 or the number 0 $var = 0; or $var = "0″

The value of the 3 variable is flase $var = flase;

4 Null is empty

5 Empty array $arr =array ();

The 6 variable only defines $var that are not assigned value;

These whole fake

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Summary of Php:empty,isset,is_null,array (0), array (), Array (""), 0, "0", "", "null", NULL

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.