Pro PHP- Patterns, Frameworks, Testing and More
CHAPTER 11 ■ SPL FILE AND DIRECTORY HANDLING^175 $fpLoc = ftell($this->fp); $data = $this->fgetcsv(); fseek($this->fp, ...
(^176) CHAPTER 11 ■ SPL FILE AND DIRECTORY HANDLING ["To"]=> string(0) "" } [1]=> array(3) { ["Prime Minister"]=> strin ...
CHAPTER 11 ■ SPL FILE AND DIRECTORY HANDLING^177 class FileContentFilter extends FilterIterator { protected $search; public func ...
(^178) CHAPTER 11 ■ SPL FILE AND DIRECTORY HANDLING The final example in this chapter demonstrated how to create a basic substri ...
179 ■ ■ ■ CHAPTER 12 SPL Array Overloading Array overloading is the process of using an object as an array. Some people coming f ...
(^180) CHAPTER 12 ■ SPL ARRAY OVERLOADING public function offsetSet($offset, $value) { $this->_arr[$offset] = $value; } publi ...
CHAPTER 12 ■ SPL ARRAY OVERLOADING^181 Listing 12-2. Using ArrayObject $myArray = new ArrayObject(); $myArray['first'] = 'test'; ...
(^182) CHAPTER 12 ■ SPL ARRAY OVERLOADING So this could be useful, but it’s hardly worth getting up off the couch for. The power ...
CHAPTER 12 ■ SPL ARRAY OVERLOADING^183 Listing 12-4. Cart Object require_once('Product.php'); class Cart extends ArrayObject { p ...
(^184) CHAPTER 12 ■ SPL ARRAY OVERLOADING Listing 12-5. Adding a getCartTotal Method public function getCartTotal() { for( $i=$s ...
CHAPTER 12 ■ SPL ARRAY OVERLOADING^185 The SPL has a solution to this problem. In Chapter 9, you were introduced to the spl_obje ...
(^186) CHAPTER 12 ■ SPL ARRAY OVERLOADING public function offsetExists($key) { return array_key_exists(spl_object_hash($key), $t ...
CHAPTER 12 ■ SPL ARRAY OVERLOADING^187 parent::__construct(&$this->_values); } public function offsetSet($key, $value) { ...
(^188) CHAPTER 12 ■ SPL ARRAY OVERLOADING Just the Facts This chapter explained how to use objects as arrays. This is accomplish ...
189 ■ ■ ■ CHAPTER 13 SPL Exceptions The SPL provides a number of built-in exception base classes that are designed to handle eve ...
(^190) CHAPTER 13 ■ SPL EXCEPTIONS public function getName() { if(!$this->_loaded) { throw new LogicException('Call materiali ...
CHAPTER 13 ■ SPL EXCEPTIONS^191 the log. There is no need to close the file handle, as this will be done for you when the class ...
(^192) CHAPTER 13 ■ SPL EXCEPTIONS } else { //Abort transaction throw new RuntimeException("The account has insufficient funds." ...
CHAPTER 13 ■ SPL EXCEPTIONS^193 Range Exceptions The RangeException class is designed to handle range exceptions. class RangeExc ...
(^194) CHAPTER 13 ■ SPL EXCEPTIONS Fatal error: Uncaught exception 'RangeException' with message 'The sensor broke down.' in lis ...
«
6
7
8
9
10
11
12
13
14
15
»
Free download pdf