PHP isset() Function | What is isset in PHP and Use with Example?
Summary: In this article, you will learn what is PHP isset() function and how to use them. Therefore, also you will learn Why to check both isset() and !empty() function in PHP?
What is PHP isset() function?
PHP has two Identical functions that are necessary to writing PHP applications, but whose aim and exact function is rarely well explained: isset and empty. The PHP isset() function is used to checks whether a variable is set, which implies that it has to be declared and isn’t NULL. If a variable is already unset with the unset() function, it’ll now not be set.
This function returns true if the variable exists and isn’t NULL, otherwise, it returns false.
Syntax:
Parameter Value:
| Parameter Value | Description | Type |
|---|---|---|
| variable1 | It is a required parameter, Specifies the variable being checked | Mixed* |
| variable2 | It is optional parameter. furthermore, another more variable to be checked. | Mixed* |
| variable3 | It is optional parameter. furthermore, another more variable to be checked. | Mixed* |
Return Value:
TRUE if variable (variable1, variable2, variable3) exists and has a value not equal to NULL, FALSE otherwise.
PHP isset() Function Example
Program:1
Program:2
boolean true
boolean true
boolean false
boolean false
boolean false
Q.1 Why to check both isset() and !empty() function in PHP ?
Reason to check both function:- As you know that isset() and !empty() both function are similar. they will return Identical results. however, the only difference is !empty() function will not generate a warning when the variable doesn’t exist. It’s enough to use either of the function. Here, both functions in a program cause time-lapse and unnecessary memory usage.
1 is set with !empty function
Conclusion:
In this article, you have learned PHP isset() and to check both isset() and !empty() function in PHP ? I hope you will enjoy it!. if have any query related program then contact me at info@tutorialscan.com I will try to resolve the problem.
Stay healthy, stay safe! Happy coding! enjoy it!