This is my first php program!



Download 6,9 Mb.
Pdf ko'rish
bet46/69
Sana26.02.2022
Hajmi6,9 Mb.
#471647
1   ...   42   43   44   45   46   47   48   49   ...   69
Bog'liq
PHP

54
|
Chapter 2: Language Basics
The alternate syntax is:
foreach (
$array
as
$key => $value
):
// ...
endforeach;
declare
The
declare
statement allows you to specify execution directives for a block of code.
The structure of a
declare
statement is:
declare (
directive
)
statement
Currently, there is only one
declare
form, the ticks directive. Using it, you can spec-
ify how frequently (measured roughly in number of code statements) a tick function
registered with
register_tick_function( )
is called. For example:
register_tick_function("some_function");
declare(ticks = 3) {
for($i = 0; $i < 10; $i++) {
// do something
}
}
In this code,
some_function( )
is called after every third statement is executed.
exit and return
The
exit
statement ends execution of the script as soon as it is reached. The
return
statement returns from a function or (at the top level of the program) from the script.
The
exit
statement takes an optional value. If this is a number, it’s the exit status of
the process. If it’s a string, the value is printed before the process terminates. The
exit( )
construct is an alias for
die( )
:
$handle = @mysql_connect("localhost", $USERNAME, $PASSWORD);
if (!$handle) {
die("Could not connect to database");
}
This is more commonly written as:
$handle = @mysql_connect("localhost", $USERNAME, $PASSWORD)
or die("Could not connect to database");
See Chapter 3 for more information on using the
return
statement in functions.
Including Code
PHP provides two constructs to load code and HTML from another module:
require
and
include
. They both load a file as the PHP script runs, work in conditionals and
,ch02.15294 Page 54 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   ...   42   43   44   45   46   47   48   49   ...   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