Skip to Content
PHP编程:第4版
book

PHP编程:第4版

by Kevin Tatroe, Peter MacIntyre
January 2021
Intermediate to advanced
505 pages
9h 45m
Chinese
Publishing House of Electronics Industry
Content preview from PHP编程:第4版
表达式和操作符
41
被递增的值 结果
"z" "aa"
"spaz" "spba"
"k9" "L0"
"42" "43"
比较操作符
顾名思义,比较操作符用于比较操作数。如果比较结果为真,它会返回
true
,否则返回
false
。用于比较的两个操作数可以都为数字、都为字符串或者一个数字与一个字符串。
比较操作符会根据操作数的类型和数值进行比较。两个操作数之间可能使用严格的数字
比较,或者字典(文本)比较。表
2-7
列举了各种操作数类型用到的比较方式。
2-7:比较操作符对应的不同的比较关系
第一个操作数 第二个操作数 比较关系
数字 数字 数字
完全是数字的字符串 完全是数字的字符串 数字
完全是数字的字符串 数字 数字
完全是数字的字符串 不完全是数字的字符串 字典
不完全是数字的字符串 数字 数字
不完全是数字的字符串 不完全是数字的字符串 字典
值得注意的是,如果操作数是两个数字字符串,它们会被当成数字进行比较。如果需要
对两个全部由数字组成的字符串进行字典比较,可以使用
strcmp()
函数。
比较操作符有如下几种
等于(
==
如果两个操作数相等,则操作符返回
true
,否则返回
false
全等(
===
如果两个操作数相等,并且类型相同,操作符返回
true
,否则返回
false
。该操作
符不做隐式类型转换,所以当你想知道两个变量类型是否一样时,它会非常有用。
简单的比较可能涉及数值转换。例如,字符串
"0.0"
"0"
,使
==
会认为它们相等,
而使用
===
会认为它们不相等。
不等(
!=
或者
<>
如果两个操作数不相等,返回 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley
算法技术手册(原书第2 版)

算法技术手册(原书第2 版)

George T.Heineman, Gary Pollice, Stanley Selkow
Java持续交付

Java持续交付

Daniel Bryant, Abraham Marín-Pérez

Publisher Resources

ISBN: 9787121404634