

How to check whether a variable is null in PHP
source link: https://www.laravelcode.com/post/how-to-check-whether-a-variable-is-null-in-php
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

How to check whether a variable is null in PHP
Use the PHP is_null()
function
You can use the PHP is_null()
function to check whether a variable is null or not.
Let's check out an example to understand how this function works:
<?php
$var = NULL;
// Testing the variables
if(is_null($var)){
echo 'This line is printed, because the $var is null.';
}
echo "<br>";
if(is_null($inexistent)){
echo 'This line is printed, because the $inexistent is null.';
}
?>
i hope you like this article.
Author : Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
Recommend
-
22
In the June 24th C# Language Design Meeting , Microsoft made a subtle change to the
-
8
Is it logical to check the null values in the injected arguments? advertisements I am using unity in my application. Does it make sense to c...
-
10
Javascript Check If an Object Is Null or Undefined While working in javascript, often we encounter a requirement that is to determine if the object is null or not. We might require this check to verify that th...
-
12
How to check whether a variable is empty in PHP 1091 views 1 year ago PHP Use the PHP empty()
-
8
Sometimes we need to check if an value/object/variable in JavaScript is null. For example, querySelector for elements will return null if nothing found, or event state in the callback of history API is null in some cases. In this pos...
-
4
When checking if an event handler is null, is this done on a per-thread basis? Ensuring someone is listening to the event is done like this:...
-
4
How to check whether a number is Fibonacci or not in PHP? Member by
-
13
How to check whether a variable is set or not in PHP 1600 views 2 years ago PHP Use the PHP isset()
-
6
How to determine if variable is undefined or null in JavaScript 1482 views 2 years ago jQuery Use the equal...
-
7
Check if all elements in array are null in PHP This tutorial will discuss about a unique way to check if all elements in array are null. We can use the array_reduce() function to get the work done h...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK