Pro PHP- Patterns, Frameworks, Testing and More
CHAPTER 2 ■ STATIC VARIABLES, MEMBERS, AND METHODS^15 New Functionality Standard Functionality Static members can also belong to ...
(^16) CHAPTER 2 ■ STATIC VARIABLES, MEMBERS, AND METHODS All of the prior examples use instances of classes to access methods. Y ...
CHAPTER 2 ■ STATIC VARIABLES, MEMBERS, AND METHODS^17 Listing 2-7. Invoking a Static Method class MyObject { static function myM ...
(^18) CHAPTER 2 ■ STATIC VARIABLES, MEMBERS, AND METHODS Listing 2-8 generates the following output: Called from MyExtendedObjec ...
CHAPTER 2 ■ STATIC VARIABLES, MEMBERS, AND METHODS^19 To access static methods, you use the paamayim nekudotayim operator (::), ...
McArthur_819-9C02.fm Page 20 Friday, February 1, 2008 10:23 AM ...
21 ■ ■ ■ CHAPTER 3 Singleton and Factory Patterns Patterns are like recipes for OOP developers, with each pattern providing the ...
(^22) CHAPTER 3 ■ SINGLETON AND FACTORY PATTERNS Unlike a normal class, a singleton class cannot be directly instantiated within ...
CHAPTER 3 ■ SINGLETON AND FACTORY PATTERNS^23 Next are the private __construct() and __clone() magic methods. The private constr ...
(^24) CHAPTER 3 ■ SINGLETON AND FACTORY PATTERNS decide which class should be instantiated, based on application logic or a conf ...
CHAPTER 3 ■ SINGLETON AND FACTORY PATTERNS^25 class Image_PNG implements IImage { private $_width, $_height, $_data; public func ...
(^26) CHAPTER 3 ■ SINGLETON AND FACTORY PATTERNS public function getHeight() { return $this->_height; } public function getDa ...
CHAPTER 3 ■ SINGLETON AND FACTORY PATTERNS^27 to determine which class should be called, and then call a specific class, replica ...
(^28) CHAPTER 3 ■ SINGLETON AND FACTORY PATTERNS } else { return false; } } } class MYSQL implements IDatabaseBindings { protect ...
CHAPTER 3 ■ SINGLETON AND FACTORY PATTERNS^29 The code creates a DatabaseFactory class that will instantiate and return IDatabas ...
McArthur_819-9C03.fm Page 30 Friday, February 1, 2008 10:24 AM ...
31 ■ ■ ■ CHAPTER 4 Exceptions Introduced in PHP 5, exceptions are a critical part of any OOP application. The term exception ref ...
(^32) CHAPTER 4 ■ EXCEPTIONS catch The catch block defines what to do in the case of an exception. It allows you to define the t ...
CHAPTER 4 ■ EXCEPTIONS^33 Once constructed, an exception knows several key things: where it was constructed, what code was execu ...
(^34) CHAPTER 4 ■ EXCEPTIONS When thrown, this exception generates the following message: Could not connect to the database Firs ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf