What does null value mean in PHP

云罗郡主
Release: 2023-04-04 18:52:01
Original
5045 people have browsed it

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;       
?>
Copy after login
is_null ( mixed $var ) : bool
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template