This is my first php program!



Download 6,9 Mb.
Pdf ko'rish
bet32/69
Sana26.02.2022
Hajmi6,9 Mb.
#471647
1   ...   28   29   30   31   32   33   34   35   ...   69
Bog'liq
PHP

Comparison Operators
As their name suggests, comparison operators compare operands. The result is
always either
true
, if the comparison is truthful, or
false
, otherwise.
Operands to the comparison operators can be both numeric, both string, or one
numeric and one string. The operators check for truthfulness in slightly different
ways based on the types and values of the operands, either using strictly numeric
comparisons or using lexicographic (textual) comparisons. Table 2-7 outlines when
each type of check is used.
Table 2-5. Autoincrement and autodecrement operations
Operator
Name
Value returned
Effect on $var
$var++
Post-increment
$var
Incremented
++$var
Pre-increment
$var + 1
Incremented
$var--
Post-decrement
$var
Decremented
--$var
Pre-decrement
$var – 1
Decremented
Table 2-6. Autoincrement with letters
Incrementing this
Gives this
"a"
"b"
"z"
"aa"
"spaz"
"spba"
"K9"
"L0"
"42"
"43"
,ch02.15294 Page 39 Wednesday, March 13, 2002 11:42 AM


This is the Title of the Book, eMatter Edition
Copyright © 2002 O’Reilly & Associates, Inc. All rights reserved.
40
|
Chapter 2: Language Basics
One important thing to note is that two numeric strings are compared as if they were
numbers. If you have two strings that consist entirely of numeric characters and you
need to compare them lexicographically, use the
strcmp( )
function.
The comparison operators are:
Equality (
==
)
If both operands are equal, this operator returns
true
; otherwise, it returns
false
.
Identical (
===
)
If both operands are equal and are of the same type, this operator returns
true
;
otherwise, it returns
false
. Note that this operator does
not
do implicit type
casting. This operator is useful when you don’t know if the values you’re com-
paring are of the same type. Simple comparison may involve value conversion.
For instance, the strings
"0.0"
and
"0"
are not equal. The
==
operator says they
are, but
===
says they are not.
Inequality (
!=
 or
<>
)
If both operands are not equal, this operator returns
true
; otherwise, it returns
false
.
Not identical (
!==
)
If both operands are not equal, or they are not of the same type, this operator
returns
true
; otherwise, it returns
false
.
Greater than (
>
)
If the lefthand operator is greater than the righthand operator, this operator
returns
true
; otherwise, it returns
false
.
Greater than or equal to (
>=
)
If the lefthand operator is greater than or equal to the righthand operator, this
operator returns
true
; otherwise, it returns
false
.
Less than (
<
)
If the lefthand operator is less than the righthand operator, this operator returns
true
; otherwise, it returns
false
.
Less than or equal to (
<=
)
If the lefthand operator is less than or equal to the righthand operator, this oper-
ator returns
true
; otherwise, it returns
false
.
Table 2-7. Type of comparision performed by the comparision operators

Download 6,9 Mb.

Do'stlaringiz bilan baham:
1   ...   28   29   30   31   32   33   34   35   ...   69




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish