Understanding NULL in PHP: Handling Absence of Value

Rumman Ansari   Software Engineer   2024-07-09 10:06:53   5445  Share
Subject Syllabus DetailsSubject Details
☰ TContent
☰Fullscreen

Table of Content:

Null is a special data type which can have only one value: NULL.

A variable of data type NULL is a variable that has no value assigned to it.

Tip: If a variable is created without a value, it is automatically assigned a value of NULL.

Variables can also be emptied by setting the value to NULL:

Syntax:



<?php
$x = "Hello world!";
$x = null;
var_dump($x);
?>