Home >Backend Development >PHP Tutorial >What does null value mean in PHP

What does null value mean in PHP

云罗郡主
云罗郡主Original
2019-01-15 14:15:205086browse

What does null value mean in PHP

1: What does the null value mean?

NULL is a special mark in php. The NULL value means that a variable has no value. NULL The only possible value of the type is NULL.

A variable is considered NULL under the following circumstances:

1. It is assigned a value of NULL.

2. It has not been assigned a value.

3. Be unset().

2: Syntax

The NULL type has only one value, which is the case-insensitive constant NULL.

<?php
$var = NULL;       
?>
is_null ( mixed $var ) : bool

Returns TRUE if var is null, otherwise returns FALSE.

Look at the NULL type to know when a variable is considered NULL.

Three: Converting to NULL

Using (unset) $var Converting a variable to null will not delete the variable or unset its value. Just returns a NULL value.

Note: Empty arrays are converted to null via non-strict equality '==' comparisons. If it is possible to get an empty array, use is_null() or '==='.

$a = array();
$a == null  <== return true
$a === null < == return false
is_null($a) <== return false

NULL should represent no value and not be considered the value itself.

NULL is a null bit, this is missing information, talking about "null value" is a semantic awkwardness, but if a variable can exist without a value, then the language and implementation must have something to represent this situation.


The above is the detailed content of What does null value mean in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn