This is my first php program!



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

50
|
Chapter 2: Language Basics
case 'bruno':
print('yes');
break;
default:
print('no');
break;
}
Commenting the fact that you are using a fall-through case in a
switch
is a good idea,
so someone doesn’t come along at some point and add a
break
, thinking you had for-
gotten it.
You can specify an optional number of levels for the break keyword to break out of.
In this way, a
break
statement can break out of several levels of nested
switch
state-
ments. An example of using
break
in this manner is shown in the next section.
while
The simplest form of loop is the
while
statement:
while (
expression
)
statement
If the
expression
evaluates to
true
, the
statement
is executed and then the
expression
is reevaluated (if it is
true
, the body of the loop is executed, and so on). The loop
exits when the
expression
evaluates to
false
.
As an example, here’s some code that adds the whole numbers from 1 to 10:
$total = 0;
$i = 1;
while ($i <= 10) {
$total += $i;
}
The alternative syntax for
while
has this structure:
while (
expr
):
statement;
...
;
endwhile;
For example:
$total = 0;
$i = 1;
while ($i <= 10):
$total += $i;
endwhile;
You can prematurely exit a loop with the
break
keyword. In the following code,
$i
never reaches a value of
6
, because the loop is stopped once it reaches
5
:
$total = 0;
$i = 1;
while ($i <= 10) {
,ch02.15294 Page 50 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   ...   39   40   41   42   43   44   45   46   ...   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