..
$state["Wyoming"] = "Cheyenne";
Arrays are formally introduced in Chapter 5, so don??™t worry too much about the
matter if you don??™t completely understand these concepts right now.
68 CHAPTER 3 ?– PHP B ASICS
?– Note PHP also supports arrays consisting of several dimensions, better known as multidimensional
arrays. This concept is introduced in Chapter 5.
Object
The other compound datatype supported by PHP is the object. The object is a central
concept of the object-oriented programming paradigm. If you??™re new to objectoriented
programming, Chapters 6 and 7 are devoted to the topic.
Unlike the other datatypes contained in the PHP language, an object must be explicitly
declared. This declaration of an object??™s characteristics and behavior takes place
within something called a class. Here??™s a general example of a class definition and
subsequent invocation:
class Appliance {
private $_power;
function setPower($status) {
$this->_power = $status;
}
}
...
$blender = new Appliance;
A class definition creates several attributes and functions pertinent to a data structure,
in this case a data structure named Appliance. There is only one attribute, power,
which can be modified by using the method setPower().
Remember, however, that a class definition is a template and cannot itself be manipulated.
Instead, objects are created based on this template.
Pages:
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153