Hi
I want to know, what is the use of isset() function in PHP ? Please tell me anyone use of the isset() function in PHP with an example ?
Thanks
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
SenthilkumarRank #387 · 6.5K reputationPosted Apr 10, 2012, 7:48 PM EDT
iiset() Determines if a variable is set and is not NULL.
There are plenty of example.please go here:
http://php.net/manual/en/function.isset.php
http://www.toknowmore.net/e/1/php/php-isset-function.php
http://itslennysfault.com/php-isset-vs-empty
http://snipplr.com/view/11093/
Satyapriya NayakRank #47 · 31.5K reputationPosted Apr 10, 2012, 7:49 PM EDT
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.
Refer
http://www.java-samples.com/showtutorial.php?tutorialid=891
Thanks