This is my first php program!



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

Flow-Control Statements
|
47
if
The
if
statement checks the truthfulness of an expression and, if the expression is
true, evaluates a statement. An
if
statement looks like:
if (
expression
)
statement
To specify an alternative statement to execute when the expression is false, use the
else
keyword:
if (
expression
)
statement
else
statement
For example:
if ($user_validated)
echo "Welcome!";
else
echo "Access Forbidden!";
To include more than one statement in an
if
statement, use a
block
—a curly brace-
enclosed set of statements:
if ($user_validated) {
echo 'Welcome!";
$greeted = 1;
} else {
echo "Access Forbidden!";
exit;
}
PHP provides another syntax for blocks in tests and loops. Instead of enclosing the
block of statements in curly braces, end the
if
line with a colon (
:
) and use a specific
keyword to end the block (
endif
, in this case). For example:
if ($user_validated) :
echo "Welcome!";
$greeted = 1;
else :
echo "Access Forbidden!";
exit;
endif;
Other statements described in this chapter also have similar alternate style syntax
(and ending keywords); they can be useful if you have large blocks of HTML inside
your statements. For example:





,ch02.15294 Page 47 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.
First Name:Sophia

Download 6,9 Mb.

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