This is my first php program!



Download 6,9 Mb.
Pdf ko'rish
bet42/69
Sana26.02.2022
Hajmi6,9 Mb.
#471647
1   ...   38   39   40   41   42   43   44   45   ...   69
Bog'liq
PHP

Flow-Control Statements
|
49
A
switch
statement is given an expression and compares its value to all cases in the
switch; all statements in a matching case are executed, up to the first
break
keyword
it finds. If none match, and a
default
is given, all statements following the
default
keyword are executed, up to the first
break
keyword encountered.
For example, suppose you have the following:
if ($name == 'ktatroe')
// do something
elseif ($name == 'rasmus')
// do something
elseif ($name == 'ricm')
// do something
elseif ($name == 'bobk')
// do something
You can replace that statement with the following
switch
statement:
switch($name) {
case 'ktatroe':
// do something
break;
case 'rasmus':
// do something
break;
case 'ricm':
// do something
break;
case 'bobk':
// do something
break;
}
The alternative syntax for this is:
switch($name):
case 'ktatroe':
// do something
break;
case 'rasmus':
// do something
break;
case 'ricm':
// do something
break;
case 'bobk':
// do something
break;
endswitch;
Because statements are executed from the matching case label to the next
break
key-
word, you can combine several cases in a
fall-through
. In the following example,
“yes” is printed when
$name
is equal to “sylvie” or to “bruno”:
switch ($name) {
case 'sylvie': // fall-through
,ch02.15294 Page 49 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.

Download 6,9 Mb.

Do'stlaringiz bilan baham:
1   ...   38   39   40   41   42   43   44   45   ...   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