Preface |
|
xv | |
|
|
1 | (23) |
|
|
3 | (2) |
|
|
5 | (1) |
|
Processing a String One Character at a Time |
|
|
6 | (1) |
|
Reversing a String by Word or Character |
|
|
7 | (1) |
|
Expanding and Compressing Tabs |
|
|
8 | (2) |
|
|
10 | (2) |
|
Interpolating Functions and Expressions Within Strings |
|
|
12 | (1) |
|
Trimming Blanks from a String |
|
|
13 | (1) |
|
Parsing Comma-Separated Data |
|
|
14 | (1) |
|
Parsing Fixed-Width Delimited Data |
|
|
15 | (2) |
|
|
17 | (3) |
|
Wrapping Text at a Certain Line Length |
|
|
20 | (1) |
|
Storing Binary Data in Strings |
|
|
21 | (3) |
|
|
24 | (18) |
|
Checking Whether a String Contains a Valid Number |
|
|
25 | (1) |
|
Comparing Floating-Point Numbers |
|
|
26 | (1) |
|
Rounding Floating-Point Numbers |
|
|
27 | (1) |
|
Operating on a Series of Integers |
|
|
28 | (1) |
|
Generating Random Numbers Within a Range |
|
|
29 | (2) |
|
Generating Biased Random Numbers |
|
|
31 | (1) |
|
|
32 | (1) |
|
|
32 | (1) |
|
|
33 | (1) |
|
|
34 | (2) |
|
Calculating Trigonometric Functions |
|
|
36 | (1) |
|
Doing Trigonometry in Degrees, not Radians |
|
|
37 | (1) |
|
Handling Very Large or Very Small Numbers |
|
|
37 | (2) |
|
|
39 | (1) |
|
Calculating Using Numbers in Bases Other Than Decimal |
|
|
40 | (2) |
|
|
42 | (33) |
|
Finding the Current Date and Time |
|
|
43 | (3) |
|
Converting Time and Date Parts to an Epoch Timestamp |
|
|
46 | (1) |
|
Converting an Epoch Timestamp to Time and Date Parts |
|
|
47 | (1) |
|
Printing a Date or Time in a Specified Format |
|
|
48 | (4) |
|
Finding the Difference of Two Dates |
|
|
52 | (2) |
|
Finding the Difference of Two Dates with Julian Days |
|
|
54 | (1) |
|
Finding the Day in a Week, Month, Year, or the Week Number in a Year |
|
|
55 | (2) |
|
|
57 | (2) |
|
Parsing Dates and Times from Strings |
|
|
59 | (2) |
|
Adding to or Subtracting from a Date |
|
|
61 | (1) |
|
Calculating Time with Time Zones |
|
|
62 | (5) |
|
Accounting for Daylight Saving Time |
|
|
67 | (1) |
|
Generating a High-Precision Time |
|
|
68 | (1) |
|
|
69 | (1) |
|
Using Non-Gregorian Calendars |
|
|
70 | (1) |
|
|
71 | (4) |
|
|
75 | (42) |
|
Specifying an Array Not Beginning at Element 0 |
|
|
78 | (1) |
|
Storing Multiple Elements per Key in an Array |
|
|
79 | (1) |
|
Initializing an Array to a Range of Integers |
|
|
80 | (1) |
|
Iterating Through an Array |
|
|
81 | (2) |
|
Deleting Elements from an Array |
|
|
83 | (2) |
|
|
85 | (2) |
|
Appending One Array to Another |
|
|
87 | (2) |
|
Turning an Array into a String |
|
|
89 | (2) |
|
Printing an Array with Commas |
|
|
91 | (1) |
|
Checking if a Key Is in an Array |
|
|
92 | (1) |
|
Checking if an Element Is in an Array |
|
|
92 | (2) |
|
Finding the Position of an Element in an Array |
|
|
94 | (1) |
|
Finding Elements That Pass a Certain Test |
|
|
95 | (1) |
|
Finding the Largest or Smallest Valued Element in an Array |
|
|
96 | (1) |
|
|
97 | (1) |
|
|
98 | (1) |
|
Sorting an Array by a Computable Field |
|
|
99 | (2) |
|
|
101 | (2) |
|
Sorting an Array Using a Method Instead of a Function |
|
|
103 | (1) |
|
|
104 | (1) |
|
Shuffling a Deck of Cards |
|
|
105 | (1) |
|
Removing Duplicate Elements from an Array |
|
|
106 | (1) |
|
Finding the Union, Intersection, or Difference of Two Arrays |
|
|
107 | (2) |
|
Finding All Element Combinations of an Array |
|
|
109 | (2) |
|
Finding All Permutations of an Array |
|
|
111 | (3) |
|
Program: Printing an Array in a Horizontally Columned HTML Table |
|
|
114 | (3) |
|
|
117 | (14) |
|
Avoiding == Versus = Confusion |
|
|
118 | (1) |
|
Establishing a Default Value |
|
|
119 | (1) |
|
Exchanging Values Without Using Temporary Variables |
|
|
120 | (1) |
|
Creating a Dynamic Variable Name |
|
|
120 | (2) |
|
|
122 | (1) |
|
Sharing Variables Between Processes |
|
|
123 | (2) |
|
Encapsulating Complex Data Types as a String |
|
|
125 | (2) |
|
Dumping Variable Contents as Strings |
|
|
127 | (4) |
|
|
131 | (17) |
|
Accessing Function Parameters |
|
|
132 | (1) |
|
Setting Default Values for Function Parameters |
|
|
133 | (2) |
|
Passing Values by Reference |
|
|
135 | (1) |
|
|
136 | (1) |
|
Creating Functions That Take a Variable Number of Arguments |
|
|
137 | (3) |
|
Returning Values by Reference |
|
|
140 | (1) |
|
Returning More Than One Value |
|
|
140 | (2) |
|
Skipping Selected Return Values |
|
|
142 | (1) |
|
|
143 | (1) |
|
Calling Variable Functions |
|
|
144 | (1) |
|
Accessing a Global Variable Inside a Function |
|
|
145 | (2) |
|
Creating Dynamic Functions |
|
|
147 | (1) |
|
|
148 | (20) |
|
|
152 | (1) |
|
Defining Object Constructors |
|
|
153 | (1) |
|
|
154 | (1) |
|
|
154 | (1) |
|
Assigning Object References |
|
|
155 | (1) |
|
Calling Methods on an Object Returned by Another Method |
|
|
156 | (1) |
|
Accessing Overridden Methods |
|
|
157 | (2) |
|
Using Property Overloading |
|
|
159 | (1) |
|
Using Method Polymorphism |
|
|
160 | (3) |
|
Finding the Methods and Properties of an Object |
|
|
163 | (1) |
|
Adding Properties to a Base Object |
|
|
164 | (1) |
|
Creating a Class Dynamically |
|
|
165 | (1) |
|
Instantiating an Object Dynamically |
|
|
166 | (2) |
|
|
168 | (48) |
|
|
169 | (2) |
|
|
171 | (1) |
|
|
171 | (1) |
|
Redirecting to a Different Location |
|
|
172 | (1) |
|
|
173 | (2) |
|
Storing Sessions in a Database |
|
|
175 | (4) |
|
Detecting Different Browsers |
|
|
179 | (1) |
|
Building a GET Query String |
|
|
180 | (2) |
|
Using HTTP Basic Authentication |
|
|
182 | (2) |
|
Using Cookie Authentication |
|
|
184 | (3) |
|
Flushing Output to the Browser |
|
|
187 | (1) |
|
Buffering Output to the Browser |
|
|
187 | (2) |
|
Compressing Web Output with gzip |
|
|
189 | (1) |
|
Hiding Error Messages from Users |
|
|
190 | (1) |
|
|
191 | (2) |
|
Using a Custom Error Handler |
|
|
193 | (1) |
|
|
194 | (1) |
|
Eliminating ``headers already sent'' Errors |
|
|
195 | (2) |
|
Logging Debugging Information |
|
|
197 | (2) |
|
Reading Environment Variables |
|
|
199 | (1) |
|
Setting Environment Variables |
|
|
200 | (1) |
|
Reading Configuration Variables |
|
|
201 | (1) |
|
Setting Configuration Variables |
|
|
202 | (1) |
|
Communicating Within Apache |
|
|
203 | (1) |
|
|
204 | (4) |
|
Program: Website Account (De)activator |
|
|
208 | (2) |
|
Program: Abusive User Checker |
|
|
210 | (6) |
|
|
216 | (22) |
|
|
218 | (1) |
|
|
219 | (2) |
|
Working with Multipage Forms |
|
|
221 | (3) |
|
Redisplaying Forms with Preserved Information and Error Messages |
|
|
224 | (3) |
|
Guarding Against Multiple Submission of the Same Form |
|
|
227 | (2) |
|
Processing Uploaded Files |
|
|
229 | (2) |
|
Securing PHP's Form Processing |
|
|
231 | (2) |
|
Escaping Control Characters from User Data |
|
|
233 | (1) |
|
Handling Remote Variables with Periods in Their Names |
|
|
234 | (1) |
|
Using Form Elements with Multiple Options |
|
|
235 | (1) |
|
Creating Dropdown Menus Based on the Current Date |
|
|
236 | (2) |
|
|
238 | (43) |
|
Using Text-File Databases |
|
|
243 | (1) |
|
|
244 | (4) |
|
Connecting to a SQL Database |
|
|
248 | (2) |
|
|
250 | (2) |
|
Retrieving Rows Without a Loop |
|
|
252 | (2) |
|
Modifying Data in a SQL Database |
|
|
254 | (1) |
|
Repeating Queries Efficiently |
|
|
255 | (2) |
|
Finding the Number of Rows Returned by a Query |
|
|
257 | (1) |
|
|
258 | (1) |
|
Logging Debugging Information and Errors |
|
|
259 | (3) |
|
Assigning Unique ID Values Automatically |
|
|
262 | (1) |
|
Building Queries Programmatically |
|
|
263 | (4) |
|
Making Paginated Links for a Series of Records |
|
|
267 | (5) |
|
Caching Queries and Results |
|
|
272 | (2) |
|
Program: Storing a Threaded Message Board |
|
|
274 | (7) |
|
|
281 | (28) |
|
Fetching a URL with the GET Method |
|
|
283 | (2) |
|
Fetching a URL with the POST Method |
|
|
285 | (2) |
|
Fetching a URL with Cookies |
|
|
287 | (2) |
|
Fetching a URL with Headers |
|
|
289 | (1) |
|
|
290 | (1) |
|
Debugging the Raw HTTP Exchange |
|
|
290 | (3) |
|
|
293 | (2) |
|
Extracting Links from an HTML File |
|
|
295 | (1) |
|
|
296 | (1) |
|
|
297 | (1) |
|
Removing HTML and PHP Tags |
|
|
298 | (1) |
|
|
299 | (2) |
|
Parsing a Web Server Log File |
|
|
301 | (2) |
|
Program: Finding Stale Links |
|
|
303 | (2) |
|
Program: Finding Fresh Links |
|
|
305 | (4) |
|
|
309 | (34) |
|
|
311 | (2) |
|
Generating XML with the DOM |
|
|
313 | (3) |
|
|
316 | (3) |
|
|
319 | (4) |
|
Transforming XML with XSLT |
|
|
323 | (3) |
|
|
326 | (3) |
|
Receiving XML-RPC Requests |
|
|
329 | (4) |
|
|
333 | (3) |
|
|
336 | (2) |
|
Exchanging Data with WDDX |
|
|
338 | (2) |
|
|
340 | (3) |
|
|
343 | (18) |
|
Switching From ereg to preg |
|
|
346 | (2) |
|
|
348 | (1) |
|
Finding the nth Occurrence of a Match |
|
|
349 | (1) |
|
Choosing Greedy or Nongreedy Matches |
|
|
350 | (2) |
|
Matching a Valid Email Address |
|
|
352 | (3) |
|
Finding All Lines in a File That Match a Pattern |
|
|
355 | (1) |
|
Capturing Text Inside HTML Tags |
|
|
355 | (2) |
|
Escaping Special Characters in a Regular Expression |
|
|
357 | (2) |
|
Reading Records with a Pattern Separator |
|
|
359 | (2) |
|
|
361 | (22) |
|
Keeping Passwords Out of Your Site Files |
|
|
362 | (1) |
|
Obscuring Data with Encoding |
|
|
363 | (1) |
|
Verifying Data with Hashes |
|
|
364 | (2) |
|
|
366 | (1) |
|
Checking Password Strength |
|
|
367 | (2) |
|
Dealing with Lost Passwords |
|
|
369 | (2) |
|
Encrypting and Decrypting Data |
|
|
371 | (4) |
|
Storing Encrypted Data in a File or Database |
|
|
375 | (3) |
|
Sharing Encrypted Data with Another Web Site |
|
|
378 | (2) |
|
|
380 | (1) |
|
Encrypting Email with GPG |
|
|
381 | (2) |
|
|
383 | (25) |
|
Drawing Lines, Rectangles, and Polygons |
|
|
386 | (2) |
|
Drawing Arcs, Ellipses, and Circles |
|
|
388 | (2) |
|
Drawing with Patterned Lines |
|
|
390 | (1) |
|
|
391 | (3) |
|
|
394 | (4) |
|
|
398 | (3) |
|
Getting and Setting a Transparent Color |
|
|
401 | (1) |
|
|
402 | (1) |
|
Program: Generating Bar Charts from Poll Results |
|
|
403 | (5) |
|
Internationalization and Localization |
|
|
408 | (18) |
|
Listing Available Locales |
|
|
409 | (1) |
|
Using a Particular Locale |
|
|
410 | (1) |
|
Setting the Default Locale |
|
|
411 | (1) |
|
|
412 | (3) |
|
Localizing Dates and Times |
|
|
415 | (1) |
|
Localizing Currency Values |
|
|
416 | (3) |
|
|
419 | (1) |
|
Localizing Included Files |
|
|
420 | (1) |
|
Managing Localization Resources |
|
|
421 | (2) |
|
|
423 | (1) |
|
Reading or Writing Unicode Characters |
|
|
424 | (2) |
|
|
426 | (28) |
|
|
427 | (3) |
|
|
430 | (2) |
|
Reading Mail with IMAP or POP3 |
|
|
432 | (3) |
|
Posting Messages to Usenet Newsgroups |
|
|
435 | (2) |
|
Reading Usenet News Messages |
|
|
437 | (5) |
|
Getting and Putting Files with FTP |
|
|
442 | (2) |
|
Looking Up Addresses with LDAP |
|
|
444 | (2) |
|
Using LDAP for User Authentication |
|
|
446 | (2) |
|
|
448 | (2) |
|
Checking if a Host Is Alive |
|
|
450 | (1) |
|
Getting Information About a Domain Name |
|
|
451 | (3) |
|
|
454 | (39) |
|
Creating or Opening a Local File |
|
|
457 | (2) |
|
Creating a Temporary File |
|
|
459 | (1) |
|
|
460 | (1) |
|
Reading from Standard Input |
|
|
460 | (1) |
|
Reading a File into a String |
|
|
461 | (2) |
|
Counting Lines, Paragraphs, or Records in a File |
|
|
463 | (2) |
|
Processing Every Word in a File |
|
|
465 | (2) |
|
Reading a Particular Line in a File |
|
|
467 | (1) |
|
Processing a File Backward by Line or Paragraph |
|
|
468 | (1) |
|
Picking a Random Line from a File |
|
|
468 | (1) |
|
Randomizing All Lines in a File |
|
|
469 | (1) |
|
Processing Variable Length Text Fields |
|
|
470 | (1) |
|
Reading Configuration Files |
|
|
471 | (3) |
|
Reading from or Writing to a Specific Location in a File |
|
|
474 | (1) |
|
Removing the Last Line of a File |
|
|
475 | (2) |
|
Modifying a File in Place Without a Temporary File |
|
|
477 | (2) |
|
Flushing Output to a File |
|
|
479 | (1) |
|
Writing to Standard Output |
|
|
479 | (1) |
|
Writing to Many Filehandles Simultaneously |
|
|
480 | (1) |
|
Escaping Shell Metacharacters |
|
|
481 | (2) |
|
Passing Input to a Program |
|
|
483 | (1) |
|
Reading Standard Output from a Program |
|
|
484 | (1) |
|
Reading Standard Error from a Program |
|
|
485 | (1) |
|
|
486 | (3) |
|
Reading and Writing Compressed Files |
|
|
489 | (1) |
|
|
490 | (3) |
|
|
493 | (25) |
|
Getting and Setting File Timestamps |
|
|
496 | (1) |
|
|
497 | (1) |
|
Changing File Permissions or Ownership |
|
|
498 | (1) |
|
Splitting a Filename into Its Component Parts |
|
|
499 | (2) |
|
|
501 | (1) |
|
|
501 | (1) |
|
Processing All Files in a Directory |
|
|
502 | (1) |
|
Getting a List of Filenames Matching a Pattern |
|
|
503 | (1) |
|
Processing All Files in a Directory |
|
|
504 | (3) |
|
|
507 | (1) |
|
Removing a Directory and Its Contents |
|
|
508 | (1) |
|
Program: Web Server Directory Listing |
|
|
509 | (5) |
|
|
514 | (4) |
|
|
518 | (34) |
|
Parsing Program Arguments |
|
|
522 | (1) |
|
Parsing Program Arguments with getopt |
|
|
523 | (4) |
|
Reading from the Keyboard |
|
|
527 | (1) |
|
|
528 | (3) |
|
Displaying a GUI Widget in a Window |
|
|
531 | (1) |
|
Displaying Multiple GUI Widgets in a Window |
|
|
532 | (3) |
|
Responding to User Actions |
|
|
535 | (2) |
|
|
537 | (3) |
|
|
540 | (3) |
|
Program: Displaying Weather Conditions |
|
|
543 | (9) |
|
|
552 | (17) |
|
Using the PEAR Package Manager |
|
|
554 | (2) |
|
|
556 | (2) |
|
Finding Information About a Package |
|
|
558 | (1) |
|
|
559 | (2) |
|
|
561 | (1) |
|
|
562 | (2) |
|
Uninstalling PEAR Packages |
|
|
564 | (1) |
|
Documenting Classes with PHPDoc |
|
|
564 | (5) |
Index |
|
569 | |