Prev | Current Page 357 | Next

Rob Allen, Nick Lo, and Steven Brown

"Zend Framework in Action"

The fundamental goal is to produce more maintainable code ??“ that is, code that doesn??™t accidentally break
when you are working on something else.
17.1.1 Classes, objects and inheritance
In order to understand object oriented programming, you need to understand classes and objects. While we are
here, we??™ll also look at interfaces which are closely related. A class is just the code that groups functions and
variables together. That??™s all. It??™s not scary! Figure 17.1 shows a simple class.
Figure 17.1 A simple class
class ZFiA_Person A
{ B
B
} B
A ???class??? keyword defines the grouping of functions and variables
B All code for this class is between the braces
As you can see, the keyword class is used to declare the class and it is followed by its name,
???ZFiA_Person???, in this case. The name of the class has to be unique across all your files, so it is a good idea to
prefix every class name with a unique identifier. In our case, we??™ll use the prefix ???ZFiA??? and while this
introduces a modicum of hassle when writing the code, the benefits down the line when you need to integrate
your code with someone else??™s far outweighs any initial pain.
Licensed to Menshu You
Zend Framework in Action (Ch01) Manning Publications Co.


Pages:
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369
meble drewniane bet365 ATC Fotografia slubna agencja reklamowa poznań