This is my first php program!



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

28
|
Chapter 2: Language Basics
You can sort the elements of an array with the various sort functions:
sort($person);
// $person is now array('Crapper', 'Edison', 'Wankel')
asort($creator);
// $creator is now array('Toilet' => 'Crapper',
// 'Light bulb' => 'Edison',
// 'Rotary Engine' => 'Wankel');
Use the
is_array( )
function to test whether a value is an array:
if (is_array($x)) {
// $x is an array
}
There are functions for returning the number of items in the array, fetching every
value in the array, and much more. Arrays are described in Chapter 5.
Objects
PHP supports object-oriented programming (OOP). OOP promotes clean modular
design, simplifies debugging and maintenance, and assists with code reuse.
Classes are the unit of object-oriented design. A class is a definition of a structure
that contains properties (variables) and methods (functions). Classes are defined
with the
class
keyword:
class Person {
var $name = '';
function name ($newname = NULL) {
if (! is_null($newname)) {
$this->name = $newname;
}
return $this->name;
}
}
Once a class is defined, any number of objects can be made from it with the
new
key-
word, and the properties and methods can be accessed with the
->
construct:
$ed = new Person;
$ed->name('Edison');
printf("Hello, %s\n", $ed->name);
$tc = new Person;
$tc->name('Crapper');
printf("Look out below %s\n", $tc->name);
Hello, Edison
Look out below Crapper
Use the
is_object( )
function to test whether a value is an object:
if (is_object($x)) {
// $x is an object
}
,ch02.15294 Page 28 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   ...   17   18   19   20   21   22   23   24   ...   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