- Page 2 and 3: Programming PHP
- Page 4 and 5: Programming PHP by Rasmus Lerdorf a
- Page 6 and 7: Colophon Our look is the result of
- Page 8 and 9: Accessing Individual Characters 79
- Page 10 and 11: Concealing PHP Libraries 293 PHP Co
- Page 12 and 13: clarify the explanations, and the p
- Page 14 and 15: There is a web page for this book,
- Page 18 and 19: a small sample of PHP statements, i
- Page 20 and 21: C++ comments When PHP encounters tw
- Page 22 and 23: ASCII letter (uppercase or lowercas
- Page 24 and 25: Integers Integers are whole numbers
- Page 26 and 27: Table 2-2. Escape sequences in doub
- Page 28 and 29: You can sort the elements of an arr
- Page 30 and 31: Use the is_null( ) function to test
- Page 32 and 33: $counter = 10; update_counter( ); e
- Page 34 and 35: symbol table entries for $worker an
- Page 36 and 37: Number of Operands Most operators i
- Page 38 and 39: Arithmetic Operators The arithmetic
- Page 40 and 41: Table 2-7. Type of comparision perf
- Page 42 and 43: Bitwise XOR (^) The bitwise XOR ope
- Page 44 and 45: assigns $b the integer value of $a;
- Page 46 and 47: Bitwise-OR-equals (|=) Performs a b
- Page 48 and 49: Last Name:Lee Please log in. Be
- Page 50 and 51: case 'bruno': print('yes'); break;
- Page 52 and 53: You can use break and continue stat
- Page 54 and 55: The alternate syntax is: foreach ($
- Page 56 and 57: ignore subsequent attempts to load
- Page 58 and 59: Notice that there’s no trace of t
- Page 60 and 61: After processing, the resulting HTM
- Page 62 and 63: unlink( ) deletes a file $result =
- Page 64 and 65: When this page is displayed, the fu
- Page 66 and 67:
first time the function is called.
- Page 68 and 69:
Variable Parameters A function may
- Page 70 and 71:
means that returning a reference fr
- Page 72 and 73:
Chapter CHAPTER 4 4 Strings Most da
- Page 74 and 75:
Table 4-1. Escape sequences in doub
- Page 76 and 77:
echo To put a string into the HTML
- Page 78 and 79:
• Padding an integer to three dec
- Page 80 and 81:
The 1th character is e The 2th char
- Page 82 and 83:
For example: $string = htmlentities
- Page 84 and 85:
Extracting meta tags If you have th
- Page 86 and 87:
Table 4-4. Single-character escapes
- Page 88 and 89:
Table 4-5. Natural order versus ASC
- Page 90 and 91:
and spam; spam egg spam spam bacon
- Page 92 and 93:
$fields = explode(',', $input, 2);
- Page 94 and 95:
echo("The last comma in the record
- Page 96 and 97:
The Basics Most characters in a reg
- Page 98 and 99:
Alternatives You can use the vertic
- Page 100 and 101:
Table 4-7. POSIX character classes
- Page 102 and 103:
Example 4-1. Credit-card validator
- Page 104 and 105:
egular expression features. Perl re
- Page 106 and 107:
pattern. Perl provides a parallel s
- Page 108 and 109:
Inline Options In addition to speci
- Page 110 and 111:
This code snippet takes several sec
- Page 112 and 113:
Example 4-2. Extracting URLs from a
- Page 114 and 115:
Splitting Whereas you use preg_matc
- Page 116 and 117:
Chapter CHAPTER 5 5 Arrays As we di
- Page 118 and 119:
That’s an indexed array, with int
- Page 120 and 121:
Assign the results of array_pad( )
- Page 122 and 123:
) [1] => 2 [2] => 3 ) [1] => Array
- Page 124 and 125:
The size of the replacement array d
- Page 126 and 127:
PHP executes the body of the loop (
- Page 128 and 129:
Calling a Function for Each Array E
- Page 130 and 131:
Example 5-2. Searching an array (co
- Page 132 and 133:
function should return 1 if the fir
- Page 134 and 135:
We need to include $names in the fu
- Page 136 and 137:
If a string key from an earlier arr
- Page 138 and 139:
Stacks Although not as common in PH
- Page 140 and 141:
Chapter CHAPTER 6 6 Objects Object-
- Page 142 and 143:
Assuming that a Person class has be
- Page 144 and 145:
Within a method, the $this variable
- Page 146 and 147:
These arguments are passed to the c
- Page 148 and 149:
debuggers, serializers, profilers,
- Page 150 and 151:
Figure 6-1. Output of display_class
- Page 152 and 153:
Example 6-2. Object introspection f
- Page 154 and 155:
Figure 6-2. Object introspection ou
- Page 156 and 157:
Example 6-3. The Log.inc file (cont
- Page 158 and 159:
Chapter CHAPTER 7 7 Web Techniques
- Page 160 and 161:
The global arrays are: $HTTP_COOKIE
- Page 162 and 163:
CONTENT_TYPE The content type of th
- Page 164 and 165:
Example 7-1. The chunkify form (chu
- Page 166 and 167:
Example 7-3. A self-processing temp
- Page 168 and 169:
Example 7-5. Temperature conversion
- Page 170 and 171:
Example 7-7. Multiple selection val
- Page 172 and 173:
File Uploads To handle file uploads
- Page 174 and 175:
Example 7-9. Form validation (conti
- Page 176 and 177:
Different Content Types The Content
- Page 178 and 179:
$user = $_SERVER['PHP_AUTH_USER'];
- Page 180 and 181:
since midnight, January 1, 1970, GM
- Page 182 and 183:
Example 7-12. Using the color prefe
- Page 184 and 185:
Example 7-13. Setting preferences w
- Page 186 and 187:
php.ini file) and the name of the v
- Page 188 and 189:
display preferences, mailing addres
- Page 190 and 191:
automatically assigned unique row i
- Page 192 and 193:
PEAR DB Basics Example 8-1 is a pro
- Page 194 and 195:
The protocol is the communication p
- Page 196 and 197:
Storing the row The fetchInto( ) me
- Page 198 and 199:
Placeholders Just as printf( ) buil
- Page 200 and 201:
For example, this fetches the names
- Page 202 and 203:
foreach ($movies as $movie) { $id =
- Page 204 and 205:
Example 8-2. Database schema (conti
- Page 206 and 207:
Example 8-4. Backend administration
- Page 208 and 209:
Figure 8-5. The business registrati
- Page 210 and 211:
Example 8-5. Adding a business (con
- Page 212 and 213:
Example 8-6. Business listing page
- Page 214 and 215:
Chapter CHAPTER 9 9 Graphics The We
- Page 216 and 217:
FreeType Support enabled FreeType L
- Page 218 and 219:
All colors used in an image must be
- Page 220 and 221:
Basic Drawing Functions GD has func
- Page 222 and 223:
chapter) to see if your “GD” se
- Page 224 and 225:
Example 9-7. Creating a dynamic but
- Page 226 and 227:
Once button.php is installed, when
- Page 228 and 229:
Example 9-10. Resizing with ImageCo
- Page 230 and 231:
Example 9-12. A gray rectangle with
- Page 232 and 233:
Text Representation of an Image An
- Page 234 and 235:
A Simple Example Let’s start with
- Page 236 and 237:
You specify the paper size in point
- Page 238 and 239:
The output of Example 10-2 is shown
- Page 240 and 241:
You can also move the location and
- Page 242 and 243:
Stroking text means drawing a line
- Page 244 and 245:
Table 10-3. Standard PDF fonts Cour
- Page 246 and 247:
The output of Example 10-6 is shown
- Page 248 and 249:
Example 10-7. Placing and scaling i
- Page 250 and 251:
The pdf_arc( ) function draws an ar
- Page 252 and 253:
Here’s some code that experiments
- Page 254 and 255:
Figure 10-12. Pattern filling a cir
- Page 256 and 257:
Figure 10-13. A templated page Book
- Page 258 and 259:
Figure 10-14. Thumbnails The pdf_ad
- Page 260 and 261:
Example 10-14. Creating an open not
- Page 262 and 263:
Chapter CHAPTER 11 11 XML XML, the
- Page 264 and 265:
document. What if the mail message
- Page 266 and 267:
complex than it seems. The easiest
- Page 268 and 269:
What you do with a processing instr
- Page 270 and 271:
The notation parameter identifies t
- Page 272 and 273:
Example 11-8. Creating a parser (co
- Page 274 and 275:
Example 11-9. books.xml file (conti
- Page 276 and 277:
Example 11-10. bookparse.xml (conti
- Page 278 and 279:
should give you a good foundation f
- Page 280 and 281:
not much point in using this techni
- Page 282 and 283:
Often a server will call xmlrpc_ser
- Page 284 and 285:
guess. Also, there are features of
- Page 286 and 287:
Consider the following code: This
- Page 288 and 289:
HTTP or FTP URL as a filename, and
- Page 290 and 291:
as /etc/passwd or /home/rasmus/.for
- Page 292 and 293:
If you have .htaccess capabilities
- Page 294 and 295:
code, configuration files, log file
- Page 296 and 297:
Security Redux Because security is
- Page 298 and 299:
Templating Systems A templating sys
- Page 300 and 301:
Example 13-3. Template script (cont
- Page 302 and 303:
web server and clears the buffer, b
- Page 304 and 305:
By default, all conditions except r
- Page 306 and 307:
time the error happened. Your error
- Page 308 and 309:
Example 13-6. Output buffering to h
- Page 310 and 311:
Completed 300 requests Completed 40
- Page 312 and 313:
echo $time['name'] . ': ' . $time['
- Page 314 and 315:
Figure 13-2. Squid caching The rele
- Page 316 and 317:
of requests. The exact number depen
- Page 318 and 319:
Figure 14-1 shows a diagram of a we
- Page 320 and 321:
This will put a php binary in your
- Page 322 and 323:
Fleshing Out the Skeleton The rot13
- Page 324 and 325:
} php_info_print_table_start( ); ph
- Page 326 and 327:
containing extensions. Copy the mod
- Page 328 and 329:
It grabs all the config.m4 files an
- Page 330 and 331:
If you efree( ) something that was
- Page 332 and 333:
Along with this union, each contain
- Page 334 and 335:
The following code shows the rot13(
- Page 336 and 337:
The other type_spec specifying char
- Page 338 and 339:
Returning Values Knowing how to get
- Page 340 and 341:
There are three basic flavors of ar
- Page 342 and 343:
References References at the PHP so
- Page 344 and 345:
Some elements of the SAPI globals s
- Page 346 and 347:
Here is a trivial function that, wh
- Page 348 and 349:
The functions available to you are:
- Page 350 and 351:
And here’s a my_get( ) function t
- Page 352 and 353:
command prompt to test and experime
- Page 354 and 355:
You must also enable execution of s
- Page 356 and 357:
The following code shows how to tes
- Page 358 and 359:
Example 15-1. Including a remote fi
- Page 360 and 361:
Background COM is a Remote Procedur
- Page 362 and 363:
Figure 15-2. Using Word’s macro l
- Page 364 and 365:
Figure 15-4. A sample invoice creat
- Page 366 and 367:
Example 15-2. Completing and printi
- Page 368 and 369:
Open the Control Panels folder, and
- Page 370 and 371:
Figure 15-6. Sample Excel data Figu
- Page 372 and 373:
page, and actually adding the infor
- Page 375 and 376:
Appendix A APPENDIX A Function Refe
- Page 377 and 378:
Program execution escapeshellarg, e
- Page 379 and 380:
Creates an array containing all val
- Page 381 and 382:
Returns a copy of the input array p
- Page 383 and 384:
array_unique array array_unique(arr
- Page 385 and 386:
ase64_decode string base64_decode(s
- Page 387 and 388:
checkdate bool checkdate(int month,
- Page 389 and 390:
closedir void closedir([int handle]
- Page 391 and 392:
crypt string crypt(string string[,
- Page 393 and 394:
define_syslog_variables void define
- Page 395 and 396:
eregi int eregi(string pattern,stri
- Page 397 and 398:
explode array explode(string separa
- Page 399 and 400:
file array file(string path[, int i
- Page 401 and 402:
Attempts to lock the file path of t
- Page 403 and 404:
fseek int fseek(int handle, int off
- Page 405 and 406:
Writes string to the file reference
- Page 407 and 408:
the table used by htmlspecialchars(
- Page 409 and 410:
getenv string getenv(string name) R
- Page 411 and 412:
gettimeofday array gettimeofday( )
- Page 413 and 414:
hexdec int hexdec(string hex) Conve
- Page 415 and 416:
ini_set string ini_set(string varia
- Page 417 and 418:
is_long bool is_long(mixed value) R
- Page 419 and 420:
join string join(array strings,stri
- Page 421 and 422:
positive_sign Sign for positive val
- Page 423 and 424:
max mixed max(mixed value1[, mixed
- Page 425 and 426:
mt_srand void mt_srand(int seed) Se
- Page 427 and 428:
ob_gzhandler string ob_gzhandler(st
- Page 429 and 430:
an asterisk (*), which uses all arg
- Page 431 and 432:
pfsockopen int pfsockopen(string ho
- Page 433 and 434:
The parameter mode specifies the pe
- Page 435 and 436:
quotemeta string quotemeta(string s
- Page 437 and 438:
egister_tick_function void register
- Page 439 and 440:
which the error occurred, the line
- Page 441 and 442:
sin double sin(double value) Return
- Page 443 and 444:
sql_regcase string sql_regcase(stri
- Page 445 and 446:
strcmp int strcmp(string one, strin
- Page 447 and 448:
strip_tags string strip_tags(string
- Page 449 and 450:
Returns the portion of string from
- Page 451 and 452:
syslog int syslog(int priority, str
- Page 453 and 454:
ucwords string ucwords(string strin
- Page 455 and 456:
usleep void usleep(int time) Pauses
- Page 457 and 458:
Appendix B APPENDIX B Extension Ove
- Page 459 and 460:
COM The COM extension provides acce
- Page 461 and 462:
FDF The Forms Data Format (FDF) is
- Page 463 and 464:
InterBase This extension provides s
- Page 465 and 466:
To enable the mSQL extension, you m
- Page 467 and 468:
Recode The GNU Recode library conve
- Page 469:
XSLT The eXtensible Stylesheet Lang
- Page 472 and 473:
enclosing array lookup in, 120 as p
- Page 474 and 475:
arithmetic operators, 38 implicit c
- Page 476 and 477:
calendars ICAP extension, 462 MCAL
- Page 478 and 479:
comparing floating-point values, 25
- Page 480 and 481:
dates and times (continued) gettime
- Page 482 and 483:
eval() function, security risks of,
- Page 484 and 485:
financial transactions CyberMUT ext
- Page 486 and 487:
getAll() method, 199 getAssoc() met
- Page 488 and 489:
ignore_user_abort() function, 413 I
- Page 490 and 491:
length of output buffers, 301 of st
- Page 492 and 493:
N \n (newlines) end of string match
- Page 494 and 495:
parameters form accessing from PHP
- Page 496 and 497:
PHP_FE() macro, 322 phpinfo() funct
- Page 498 and 499:
egister_globals (php.ini file) disa
- Page 500 and 501:
sessions (continued) destroy handle
- Page 502 and 503:
strings (continued) quoting in PHP
- Page 504 and 505:
uncompressing and extracting PHP an
- Page 506 and 507:
Windows systems, PHP on (continued)