这两种写法齐名吗

WBOY
Release: 2016-06-13 12:20:22
Original
926 people have browsed it

这两种写法等价吗
strpos($tplpath,':') !== false
strpos($tplpath,':') !== “ ”
或strpos($tplpath,':') !== NULL
或strpos($tplpath,':') !== 0
上在是不是都是等价的
------解决思路----------------------
不等价!
strpos 函数,成功返回从0算起的偏移量,不成功返回 false
!== 不等于,比较时连同数据类型一起比较

strpos($tplpath,':') !== false  这是正确的
strpos($tplpath,':') !== “ ”  strpos要么返回数值,要么返回逻辑假,不会返回字符类型,条件恒成立
strpos($tplpath,':') !== NULL  同上
strpos($tplpath,':') !== 0  含义变了,变成判断第一个字符是否为“:”

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template