PHP Objects, Patterns and Practice (3rd edition)
CHAPTER 3 ■ OBJECT BASICS $this->playLength = $playLength; } public function getPlayLength() { return $this->playLength; } ...
CHAPTER 3 ■ OBJECT BASICS ...
C H A P T E R 4 ■ ■ ■ Advanced Features You have already seen how class type hinting and access control give you more control ov ...
CHAPTER 4 ■ ADVANCED FEATURES ■Note The static keyword was introduced with PHP 5. It cannot be used in PHP 4 scripts. Static met ...
CHAPTER 4 ■ ADVANCED FEATURES So, why would you use a static method or property? Static elements have a number of characteristic ...
CHAPTER 4 ■ ADVANCED FEATURES $row['playlength'] ); } else { $product = new ShopProduct( $row['title'], $row['firstname'], $row[ ...
CHAPTER 4 ■ ADVANCED FEATURES print ShopProduct::AVAILABLE; Attempting to set a value on a constant once it has been declared wi ...
CHAPTER 4 ■ ADVANCED FEATURES PHP Fatal error: Class ErroredWriter contains 1 abstract method and must therefore be declared abs ...
CHAPTER 4 ■ ADVANCED FEATURES The problem here is that the abstract nature of the base class is only tested when an abstract met ...
CHAPTER 4 ■ ADVANCED FEATURES //... } knows nothing at all of the ShopProduct or CdProduct types. This method is only concerned ...
CHAPTER 4 ■ ADVANCED FEATURES I create a super class named DomainObject. In a real-world project, of course, this would contain ...
CHAPTER 4 ■ ADVANCED FEATURES } class User extends DomainObject { } class Document extends DomainObject { } print_r(Document::cr ...
CHAPTER 4 ■ ADVANCED FEATURES User Object ( [group:DomainObject:private] => default ) SpreadSheet Object ( [group:DomainObjec ...
CHAPTER 4 ■ ADVANCED FEATURES } $conf = $this->xml->conf; $this->xml->addChild('item', $value)->addAttribute( 'na ...
CHAPTER 4 ■ ADVANCED FEATURES An exception is a special object instantiated from the built-in Exception class (or from a derived ...
CHAPTER 4 ■ ADVANCED FEATURES throw new Exception("file '{$this->file}' is not writeable"); } file_put_contents( $this->fi ...
CHAPTER 4 ■ ADVANCED FEATURES class ConfException extends Exception { } The LibXmlError class is generated behind the scenes whe ...
CHAPTER 4 ■ ADVANCED FEATURES // broken xml } catch ( ConfException $e ) { // wrong kind of XML file } catch ( Exception $e ) { ...
CHAPTER 4 ■ ADVANCED FEATURES Final Classes and Methods Inheritance allows for enormous flexibility within a class hierarchy. Yo ...
CHAPTER 4 ■ ADVANCED FEATURES later in the book, but you should think carefully before declaring something final. Are there real ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf