Php: null data type instances

Source: Internet
Author: User
A null value, like its name, indicates that a variable has no value. Null is case-insensitive, that is, null is the same as NULL or Null. What is a null value )?

A null value, like its name, indicates that a variable has no value. Null is case-insensitive, that is, null is the same as NULL or Null.

There are three cases where null values are granted in PHP:

First:

Not assigned

 

Code running result:

Second:

The value is NULL.

 

Code running result:

Third:

Variable processed by the unset () function

 

Code running result:

Instance

The string1 string is assigned null, and string2 has no declaration or assignment at all. Therefore, the output is null. although string3 is assigned an initial value, it is processed by the unset () function, also changed to null type. The unset () function is used to delete variables from memory. The code is as follows:

 '; Echo' variable ($ string2) is not assigned '; if (is_null ($ string2 = null )) {// Determine whether $ string1 is empty echo 'string = Null';} echo'

'; Echo' variable released by unset () ($ string3): '; unset ($ string3); if (is_null ($ string3 = null )) {// Determine whether $ string1 is empty echo 'string = Null';}?>

Code running result:

The is_null function is used to determine whether the variable is null. as we will talk about later, we will first understand that this function returns a boolean type. if the variable is null, true is returned, otherwise, false is returned. The unset () function is used to destroy known variables.

In the next section, we will explain how to convert the PHP Data type ".

The above is php: detailed description of null data type instances. For more information, see other related articles in the first PHP community!

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.