php中isset和empty区别
http://seawomen.iteye.com/blog/629786
?
php语言isset和empty的区别
empty 判断一个变量是否为“空”,isset 判断一个变量是否已经设置。正是这种所谓的“顾名思义”,令我开始时走了些弯路:
??? 1.当一个变量值等于0时,empty()也会成立(True),因而会发生一些意外。原来,empty 和 isset 虽然都是变量处理函数,它们都用来判断变量是否已经配置,它们却是有一定的区别:
??? 2.empty还会检测变量是否为空、为零。当一个变量值为0,empty 认为这个变量同等于空,即相当于没有设置。
?
??? 比如检测 $id 变量,当 $id=0 时,用empty 和 isset 来检测变量 $id 是否已经配置,两都将返回不同的值―― empty 认为没有配置,isset 能够取得 $id 的值:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31