Pro PHP- Patterns, Frameworks, Testing and More
CHAPTER 9 ■ INTRODUCTION TO SPL^135 Listing 9-8 generates the following output: The new value is 5 Serialization The SPL’s Seria ...
(^136) CHAPTER 9 ■ INTRODUCTION TO SPL Running the code in Listing 9-9 results in the following notice: Notice: serialize(): "ba ...
CHAPTER 9 ■ INTRODUCTION TO SPL^137 class Extender extends Base { private $extenderVar; public function __construct() { parent:: ...
(^138) CHAPTER 9 ■ INTRODUCTION TO SPL is called every time an undefined class or interface is called. Listing 9-12 demonstrates ...
CHAPTER 9 ■ INTRODUCTION TO SPL^139 It is critical to remember that as soon as spl_autoload_register() is called, __autoload() f ...
(^140) CHAPTER 9 ■ INTRODUCTION TO SPL //Safe to instantiate className $instance = new className(); } else { //Not safe to insta ...
CHAPTER 9 ■ INTRODUCTION TO SPL^141 This data is similar to the comparison === operator; however, some uses may benefit from a h ...
McArthur_819-9C09.fm Page 142 Thursday, February 28, 2008 1:21 PM ...
143 ■ ■ ■ CHAPTER 10 SPL Iterators As you learned in the previous chapter, in order to control looping with the foreach state- m ...
(^144) CHAPTER 10 ■ SPL ITERATORS Two base-level classes descend from Traversable and are accessible to your objects: Iterator a ...
CHAPTER 10 ■ SPL ITERATORS^145 1 2 3 ■Note Instead of writing out a foreach loop to see the contents of your iterator, you could ...
(^146) CHAPTER 10 ■ SPL ITERATORS Iterators The SPL provides iterators that are capable of iterating iterators, filtering their ...
CHAPTER 10 ■ SPL ITERATORS^147 4567 This iterator can be extremely useful for paginated display of a dataset. AppendIterator The ...
(^148) CHAPTER 10 ■ SPL ITERATORS Array ( [0] => 1 [1] => 2 [2] => 4 [3] => 5 ) ■Note The PHP 5.2.1 and later $use_k ...
CHAPTER 10 ■ SPL ITERATORS^149 The filter in Listing 10-6 rejects any entries that are not greater than three. You could also cr ...
(^150) CHAPTER 10 ■ SPL ITERATORS Listing 10-8 demonstrates the use of the GET_MATCH operational mode. Listing 10-8. Using the G ...
CHAPTER 10 ■ SPL ITERATORS^151 $iterator = new RegexIterator( $arrIterator, '/^\d*$/', RegexIterator::MATCH, RegexIterator::USE_ ...
(^152) CHAPTER 10 ■ SPL ITERATORS Listing 10-10. Using IteratorIterator and PDOStatement $db = new PDO('pgsql:dbname=yourdb;user ...
CHAPTER 10 ■ SPL ITERATORS^153 RecursiveArrayIterator The RecursiveArrayIterator allows you to create an iterator for recursive ...
(^154) CHAPTER 10 ■ SPL ITERATORS Listing 10-12. Using a RecursiveIteratorIterator Iterator $arr = array( 0 => 'a'; 1 => a ...
«
4
5
6
7
8
9
10
11
12
13
»
Free download pdf