PHP's Is_null+empty+isset+unset

Source: Internet
Author: User

Empty,isset First checks whether a variable exists , and then detects the value of the variable. and is_null Just checks the value of the variable directly, whether it is null, so if the variable is undefined, an error will occur!

later:

Detects if a variable is null with:is_null, but if the variable is undefined, it is detected with an error. Judge Null with Is_null (), if the variable is undefined, the error

Detecting whether a variable is defined can be used: isset, but it returns false if the value of a variable is: null. Determines whether the variable is defined, with Isset, and returns False if the value of the variable is null

The difference between empty and isset

1, treats $c = null, the processing on isset returns False,empty true

Unset is a direct delete variable

$a= "Hello"; $b $a ; // echo $b. ' SSS '. $a;//echo Hello unset ($b); Echo $b;  // unset is to remove the variable definition, so the output will error

Variables to assign values to each other:

  

//variable assignment of values to each other$a= "Hello";$b=$a;Echo $b.‘ SSS '.$a;//echo Hello$a= "World";Echo $b.$a;//Output Hello World description variables are assigned to each other to copy a copyunset($b);Echo $b;//unset is to remove the variable definition, so the output will error//object Mutual Assignmentclassa{ Public $num=100; }$a=NewA ();$b=$a;//point to the same object$a->num=200;Echo $b->num;//Output

Summary: variables are assigned to each other and are copies of copies. If the variable is an object, assigning values to each other is to point to the same object

RELATED links:

Http://www.cnblogs.com/chengmo/archive/2010/10/18/1854258.html

PHP's Is_null+empty+isset+unset

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.