Null Variables in PHP

A Null variable is a variable that doesn’t have a value. A variable is considered Null in following scenarios:

When creating a variable in PHP, you don’t always need to assign a value to it. You can just define the variable without a value by skipping its assignment part as shown in the below example:

<?php$username;

As you can see in the above example, we have defined a variable called $username but we have intentionally skipped assigning a value to it. When you have created a variable in this way, then that variable is considered a NULL variable.

Another situation where a variable can become NULL is that…

Kindly check https://community.geekgong.com/d/5-null-variables-in-php/ for the complete article.

Thanks.

--

--

Amila Kalansooriya

Thinker, Scholar, Teacher, problem solver, and a self-made web developer