This is my first php program!



Download 6,9 Mb.
Pdf ko'rish
bet22/69
Sana26.02.2022
Hajmi6,9 Mb.
#471647
1   ...   18   19   20   21   22   23   24   25   ...   69
Bog'liq
PHP

Data Types
|
29
Chapter 6 describes classes and objects in much more detail, including inheritance,
encapsulation (or the lack thereof), and introspection.
Resources
Many modules provide several functions for dealing with the outside world. For
example, every database extension has at least a function to connect to the database,
a function to send a query to the database, and a function to close the connection to
the database. Because you can have multiple database connections open at once, the
connect function gives you something by which to identify that connection when you
call the query and close functions: a resource.
Resources are really integers under the surface. Their main benefit is that they’re gar-
bage collected when no longer in use. When the last reference to a resource value
goes away, the extension that created the resource is called to free any memory, close
any connection, etc. for that resource:
$res = database_connect( ); // fictitious function
database_query($res);
$res = "boo"; // database connection automatically closed
The benefit of this automatic cleanup is best seen within functions, when the
resource is assigned to a local variable. When the function ends, the variable’s value
is reclaimed by PHP:
function search ( ) {
$res = database_connect( );
$database_query($res);
}
When there are no more references to the resource, it’s automatically shut down.
That said, most extensions provide a specific shutdown or close function, and it’s
considered good style to call that function explicitly when needed rather than to rely
on variable scoping to trigger resource cleanup.
Use the
is_resource( )
function to test whether a value is a resource:
if (is_resource($x)) {
// $x is a resource
}
NULL
There’s only one value of the NULL data type. That value is available through the
case-insensitive keyword
NULL
. The
NULL
value represents a variable that has no value
(similar to Perl’s
undef
or Python’s
None
):
$aleph = "beta";
$aleph = null; // variable's value is gone
$aleph = Null; // same
$aleph = NULL; // same
,ch02.15294 Page 29 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   ...   18   19   20   21   22   23   24   25   ...   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