isset() function in PHP

By: Emiley J.  

isset() determines whether a certain variable has already been declared by PHP. It returns a boolean value true if the variable has already been set, and false otherwise, or if the variable is set to the value NULL.

Consider the following script:

if (isset($first_name)) {

print '$first_name is set';


This code snippet checks whether the variable $first_name is defined. If $first_name is defined, isset() returns true , which will display ' $first_name is set. ' If it isn’t, no output is generated.

isset() can also be used on array elements and object properties. Here are examples for the relevant syntax, which you can refer to later:.

Checking an array element:

if (isset($arr["offset"])) {



Checking an object property:

if (isset($obj->property)) {



Note that in both examples, we didn’t check if $arr or $obj are set (before we checked the offset or property, respectively). The isset() construct returns false automatically if they are not set.

isset() is the only one of the three language constructs that accepts an arbitrary amount of parameters. Its accurate prototype is as follows:

isset($var1, $var2, $var3, ...);

It only returns true if all the variables have been defined; otherwise, it returns false. This is useful when you want to check if the required input variables for your script have really been sent by the client, saving you a series of single isset() checks.

Archived Comments

1. KostyaExhat
View Tutorial          By: KostyaExhat at 2017-06-16 09:47:59

2. Guestchoob
View Tutorial          By: Guestchoob at 2017-03-02 05:59:38

3. how to use isset keyword with multidimensional array
View Tutorial          By: mehul at 2015-01-19 23:47:02

4. how to use isset keyword with multidimensional array
View Tutorial          By: mehul at 2015-01-19 23:46:41

5. provides simple and easy way to learn java including SSI and Java Bean, How does apple
View Tutorial          By: Logeswari at 2013-04-30 10:46:54

6. provides simple and easy way to learn MySQL and php including

HEAP tabl

View Tutorial          By: Logeswari at 2013-04-09 05:55:25

7. if(isset($_POST["check1"]=="1"))
$check1 = $_POST["check1&

View Tutorial          By: krunal at 2012-11-22 10:30:19

8. I lik the description.
View Tutorial          By: Praveen saini at 2012-11-05 10:13:41

9. The !isset() is basically checking if the string is NOT true.
Take the first example:

View Tutorial          By: Bijan at 2012-09-21 20:49:41

10. my question is the same of sajjad.what about (!isset)?? the isset with "!" ?? what that me
View Tutorial          By: hossain at 2012-04-26 04:28:56

11. Thanks ! very information full site
View Tutorial          By: Kedar at 2012-04-22 08:53:17

12. Thanks..
Short & Sweet Description.

This is very helpful to upcoming webma

View Tutorial          By: Prashaad at 2012-02-23 17:37:14

13. this is very helpful...
View Tutorial          By: arrian at 2012-02-08 03:08:53

14. so but I cannot use isset($var) instead of $var!="" ??
View Tutorial          By: Dan at 2012-01-12 19:23:09

15. dat is wat i want to jegay with you ,......dats kool ,
View Tutorial          By: dorji wangmo at 2011-12-27 05:38:35

16. It is so simple i like it,thnx...
View Tutorial          By: Shahid Hussain at 2011-12-14 12:37:46

17. Hello ,
I have a problem in understanding completely what this wants to do !


View Tutorial          By: dimitra at 2011-10-05 16:24:11

18. this is very powerful document of isset method. thanks dude,
i understand very well.

View Tutorial          By: mehul patel at 2011-08-29 12:16:48

19. but need in the case of radio buttons
View Tutorial          By: vishnu at 2011-07-21 11:39:26

20. what about (!isset)?? the isset with "!" ?? what that mean?? i'm still confused about that
View Tutorial          By: bali web design at 2011-04-21 12:51:38

21. what about (!isset)?? the isset with "!" ?? what that mean?? i'm still confused about that
View Tutorial          By: bali web design at 2011-04-21 12:50:36

22. please give example code with defined variable.
View Tutorial          By: shajjad at 2011-02-13 20:56:09

23. I can't get it untill now. I need further explainations about it.
View Tutorial          By: johnlie at 2011-01-19 20:31:09

24. now I know what isset is for, thank you very much
View Tutorial          By: Anonymous at 2010-12-23 20:43:29

25. thanks i learnt how to use isset in php
View Tutorial          By: free web directory at 2010-09-15 19:42:28

26. ds
View Tutorial          By: sdsd at 2010-08-31 04:05:46

27. i can understand easily what is isset but i am not clear in array example (second one) partially und
View Tutorial          By: sebestiraj at 2010-04-09 00:09:36

28. Fine,you r very straightforward I like that

View Tutorial          By: Shaiju at 2010-02-21 10:15:00

29. Thanks, how about using isset() function on page/UR? e.g. if(isset($page)) {} ??? What is it for?
View Tutorial          By: Paolo at 2009-06-01 07:29:10

30. Simple and straightforward. Thats what I like about this site.
View Tutorial          By: Barand at 2009-03-21 11:03:47

Most Viewed Articles (in PHP )

Latest Articles (in PHP)

Comment on this tutorial