For beginners of PHP, the difference between empty () and isset () usage is hard to figure out, and it's hard to figure out the difference in their usage without careful thought.Let's talk about what they have in common:
Can determine
The usage of PHP empty (), isset (), and is_null () functions has been discussed a lot, and many materials may not be clear. I will repeat it again here, but I should remember it more deeply, instead of simply using program examples to speak. The
This article describes the differences among is_null, empty, isset, and unset in php. For more information, see
Is_null, empty, isset, and unset. Let's take a look at the descriptions of these four functions.
Isset determines whether a variable
Original: The use of 3 functions isset (), Empty (), and Is_numeric () for forms validationThis article briefly about the form validation in PHP three functions, it should be more common, and finally give some examples, see below.ISSET ();--suitable
When the variable is an empty string and a Boolean value of false and the value 0 o'clock, isset all returns True, directly judging all return false:
$empty='';echo (isset($empty)?'1':0);//1echo'';echo ($empty?'1':0);//0
$empty=false;echo
I recently looked at the session issue and needed to determine whether the user is logged on. I found that either of the following methods can be used to determine whether the user is logged on. The code is as follows: {code ...} problem: In the
This article mainly describes the PHP array_key_exists () and Isset () the difference between the relevant information, the need for friends can refer to the following
PHP array_key_exists is used to check if a key name exists in the array, and
This article mainly introduces the differences between isset and array_key_exists in PHP, analyzes in detail the differences between isset and array_key_exists, and analyzes the specific usage of isset and array_key_exists, for more information
Use and difference of empty, isset, and is_null in PHP, issetis_null
1. empty usage
Bool empty (mixed var)If var is a non-null or non-zero value, empty () returns FALSE. In other words, "", 0, "0", NULL, FALSE, array (), var $ var; and objects
When the variable is an empty string and a Boolean value of false and the value 0 o'clock, isset all returns True, directly judging all return false:$empty=‘‘;echo (isset($empty)?‘1‘:0);//1echo‘‘;echo ($empty?‘1‘:0);//0 $empty = False ; echo
Tested:If (isset ($ array [$ I]) {echo "exists ";}If (array_key_exists ($ I, $ array) {echo "exists ";}When the number of arrays is 10, the difference between the two is shown that the isset speed is nearly 10 times faster, but it is not very
The Isset function is to detect whether a variable is set.Format: bool Isset (mixed var [, mixed Var [, ...])return value:Returns FALSE if the variable does not existReturns FALSE if the variable exists and its value is nullReturns TURE if the
When using PHP to write a page program, I often use the variable processing function to determine whether the PHP page tail parameter of a variable value is empty, at the beginning I used to use the empty () function, but found some problems, so
ISSET (); -- this parameter is suitable for detecting whether this parameter exists.Definition and scope of action: used to test whether a variable has a value (including 0, FALSE, or an empty string, but cannot be NULL), that is, "http: //
ISSET ();--suitable for detecting the presence of this parameter.
Definition and scope: used to test whether a variable has a value (including 0,false, or an empty string, but not null), that is: "http://localhost/?fo=" is also detectable and
Empty seems to be different from isset? See the following code & lt; html & gt; & lt; head & gt; & lt; metahttp-equiv & quot; content-type & quot; content & quot; texthtml; charsetutf-8 & quot; & gt; & lt; head & gt; & lt ;? What is the difference
Empty,isset,is_null These functions, you encounter some problems. Even give your own program to bring some security problems of the bug. Most of the time, the Isset,empty are considered similar. Therefore, the development time, did not notice, a
Empty seems to be different from isset? See the following code & lt; html & gt; & lt; head & gt; & lt;/head & gt; & lt; metahttp-equiv = & quot; content-type & quot; content = & quot; text/html; c empty seems to be different from isset? See the
When using php to write page programs, I often use the variable processing function to determine whether the variable value of a parameter at the end of the php page is null. At the beginning, I used to use the empty () function, but some problems
What is the difference between a PHP array_key_exists used to check whether a key name exists in an array, and isset can also be used to detect whether a key in an array exists? This article will explain some differences in the use of
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.