Empty to determine whether a variable is "empty", isset to determine whether a variable has been set. It is this so-called "as the name implies" that I began with some detours: when a variable value is equal to 0 o'clock, empty () will also be set
Use if (isset ($ _ POST ['submit ']) {}Difference between if ($ _ POST [submit]) and if (isset ($ _ POST [submit]) when submitting a formThe first method produces a warning, and the second method is more rigorous.In addition, it is best to add
Empty,isset First checks whether a variable exists , and then detects the value of the variable. and is_null Just checks the value of the variable directly, whether it is null, so if the variable is undefined, an error will occur! later:Detects if
If there is an array,$arr = Array (' One ' is null, ' n ' = 1, ' three ' = 2);Question, if you want to determine whether the ' one ' key exists in the array: If you simply use Isset to judge the problemif (Isset ($arr [' one ')]) {echo ' presence ';}
In PHP, empty, isset, and is_null are different. if the variable is not null or a non-zero value, empty () returns FALSE. In other words, 0, 0, NULL, FALSE, array (), var $ var, undefined; and objects without any attribute will be considered empty.
Php explains why isset () is used () by default, the PHP error reporting level is not the highest, which leads to some small errors, but we cannot see the errors. according to the practice, it is found that these small errors will affect the PHP
Introduction: This is a detailed page on the differences between empty, isset, and is_null in PHP. It introduces empty, isset, is_null, PHP, differences between empty, isset, and is_null in PHP are related knowledge, skills, experience, and some PHP
Let's talk about the differences between isset and empty:
Isset determines whether the variable exists or is null if it exists. That is to say, if a variable does not exist or the variable value is null, it is considered that there is no isset,
Let's take a look at the tutorial on how to use these functions.
In_array ($array)
This function is to determine whether the current value is the array.
EX:
$array = Array (1,2);if (In_array ($array)){Die (' In_array judged it to be an array ');}
PHP's Isset () function is commonly used to detect whether a variable is setFormat: bool Isset (mixed var [, mixed Var [, ...])Function: Detect whether the variable is setreturn value:returns FALSE If the variable does not existreturns FALSE if the
Php explains why isset () is used () by default, the PHP error reporting level is not the highest, which leads to some small errors, but we cannot see the errors. according to the practice, it is found that these small errors will affect the PHP
1. For beginners of PHP, the difference between empty () and isset () usage is difficult to figure out, and the difference between their usage is hard to figure out.
Let's talk about what they have in common:
Can determine whether a variable
Overloading in PHP differs from traditional object-oriented overrides, such as in Java:
class A{ public void methodName(参数1); public void methodName(参数1,参数2); public void methodName(参数1,参数2,参数3); ...}
Overloading in PHP is an "elegant"
In php, use isset with caution to determine whether the array has a key. This article describes how to use isset in php to determine whether an array has a key. After connecting to the code, I don't know if it is a problem with php5.4, or if the
A table to figure out the difference between PHP is_null, empty, Isset, Is_nullisset
Isset to determine if a variable already exists
Empty to determine if the variable is null or 0
Is_null to determine if a variable is null
variables
1, PHP isset () function is generally used to detect whether the variable is setFormat: bool Isset (mixed var [, mixed Var [, ...])Function: Detect whether the variable is setreturn value:Returns FALSE if the variable does not existReturns FALSE if
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.