反了解决方法
Jun 13, 2016 am 10:23 AM
empty
false
quot
true
var
反了
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$a = 0;function test($a){ if($a==''){ return true; }else{ return false; }}
Copy after login
这个函数为什么反回true呢
------解决方案--------------------
var_dump($a==''); 返回什么
------解决方案--------------------
∵ $a = 0 等于空
∴ $a == '' 成立
$a === '' 就不成立了
------解决方案--------------------
0,false,‘’这三个都是 == 的,你可以用 === 来判断。
------解决方案--------------------
- PHP code
0 == null == false == '' == ""当然全等都不成立,暂时就想到这么多<br><font color="#e78608">------解决方案--------------------</font><br>參考php手冊的empty函數,和這差不多。<br>bool empty ( mixed var )<br>如果 var 是非空或非零的值,则 empty() 返回 FALSE。换句话说,""、0、"0"、NULL、FALSE、array()、var $var; 以及没有任何属性的对象都将被认为是空的,如果 var 为空,则返回 TRUE。 <br><br><br><font color="#e78608">------解决方案--------------------</font><br>
Copy after login
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

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot tools Tags

Hot Article
Repo: How To Revive Teammates
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
How Long Does It Take To Beat Split Fiction?
3 weeks ago
By DDD
R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago
By 尊渡假赌尊渡假赌尊渡假赌

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

PHP determines whether a specified key exists in an array

The role and examples of var keyword in PHP

18 Ways to Fix Audio Service Not Responding Issue on Windows 11

Let's talk about the differences between var, let and const (code example)

PHP function introduction—empty(): Check whether the variable is empty

Solution to the error AttributeError(\'{0!r} object has no attribute {1!r}\'.format(type(self).__name__, k))

Detailed explanation of the meaning of true in PHP functions
