isset vs empty vs is_null in PHP With Example

In PHP, isset vs empty vs is_null functions are most important part to start learning PHP programming.

isset(), empty() and is_null() functions are PHP in-built functions which are mainly used to check the value of the variable or initialization of the variable.

  • isset() is used to check the variable has a value or not and also the variable is not NULL.
  • empty() checks the given variable is empty. And it returns a boolean value.
  • is_null() is used to check the variable has a NULL value.
isset vs empty vs is_null in PHP With Example
isset vs empty vs is_null in PHP With Example

Here we started, isset vs empty vs is_null in PHP With Example.

PHP isset() Function

isset() is a inbuilt PHP function which is used to check the value of the variable is set or not.

The function returns the result as Boolean value True or False.

Syntax:

Example of PHP isset() Function

Output:

The variable value is not set, checked by isset()
The variable value is set, checked by isset()

PHP empty() Function

empty() is also an PHP inbuilt function which is used to check the variable’s value is empty or not.

If the value is empty then empty() function returns TRUE and if value is not empty then it returns FALSE.

Syntax:

Example of PHP empty() Function

Output:

The variable value is empty, checked by empty()
The variable value is not empty

PHP is_null() Function

PHP is_null() Function is used to find the variable value is NULL or not.

This function returns the result as a Boolean form (TRUE / FALSE).

Syntax:

Example of PHP is_null() Function

Output:

The variable value is null
The variable value is not null

Complete Difference Between isset, empty, and is_null in PHP by Using Table

 Functions“”“phpcoder”NULLFALSE0undefined
empty()TRUEFALSETRUETRUETRUETRUE
is_null()FALSEFALSETRUEFALSEFALSEERROR
isset()TRUETRUEFALSETRUETRUEFALSE
Difference Between isset, empty and is_null in PHP

Tested the above values in following PHP versions:

  • PHP 7.4
  • PHP 7.3
  • PHP 7.2
  • PHP 7.0
  • PHP 5.6
  • PHP 5.5

Conclusion

Here we discuss complete explanations of isset, empty and is_null function in PHP and what are the differences between these functions also.

To know more about these functions you can also check official site, http://www.php.net/manual/en/function.is-null.php

http://www.php.net/manual/en/function.empty.php

http://www.php.net/manual/en/function.isset.php

Also check:

Happy Coding..!

Was this article helpful?
YesNo
My name is Bikash Kr. Panda. I own and operate PHPCODER.TECH, my native place in Odisha. I am a Web Programmer by profession and working on more than 50 projects to date. My passion is working on the web-based project using PHP and relate to all CMS and frameworks which is based on PHP.
Posts created 175

2 thoughts on “isset vs empty vs is_null in PHP With Example

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Begin typing your search term above and press enter to search. Press ESC to cancel.

Back To Top
mariobet - supertotobet - escort -

takip7.com

- milanobet giriş - gizabet giriş -
perabet giriş
- betkanyon giriş -

jojobet giriş

We are now accepting guest posting and creation of back-links.
This is default text for notification bar