- 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 17 and 18:
Chapter 2 CHAPTER 2 Language Basics
- Page 19 and 20:
Comments Comments give information
- Page 21 and 22:
*/ echo("l=$l m=$m n=$n\n"); ?> Now
- Page 23 and 24:
change. Constants are referred to b
- Page 25 and 26:
PHP recognizes floating-point numbe
- Page 27 and 28:
• The empty string ("") and the s
- Page 29 and 30:
Chapter 6 describes classes and obj
- Page 31 and 32:
The old value of $black is lost. In
- Page 33 and 34:
update_counter( ); update_counter(
- Page 35 and 36:
Table 2-3. PHP operators P A Operat
- Page 37 and 38:
The division and multiplication ope
- Page 39 and 40:
Autoincrement and Autodecrement Ope
- Page 41 and 42:
Bitwise Operators The bitwise opera
- Page 43 and 44:
something is true. For example, you
- Page 45 and 46:
Because all operators are required
- Page 47 and 48:
if The if statement checks the trut
- Page 49 and 50:
A switch statement is given an expr
- Page 51 and 52:
if ($i == 5) break; // breaks out o
- Page 53 and 54:
This program adds the numbers from
- Page 55 and 56:
loops, and complain if the file bei
- Page 57 and 58:
XML Style Because of the advent of
- Page 59 and 60:
and other such niceties. Some will
- Page 61 and 62:
Chapter 3 CHAPTER 3 Functions A fun
- Page 63 and 64:
Typically, functions return some va
- Page 65 and 66:
As we discussed in Chapter 2, the e
- Page 67 and 68:
Example 3-5. Doubler redux function
- Page 69 and 70:
Missing Parameters PHP lets you be
- Page 71 and 72:
Anonymous Functions Some PHP functi
- Page 73 and 74:
echo "$who was $where"; Kilroy was
- Page 75 and 76:
As a special case, you can put a se
- Page 77 and 78:
• A padding specifier denoting th
- Page 79 and 80:
Boolean values and NULL are not mea
- Page 81 and 82:
Changing Case PHP has several funct
- Page 83 and 84:
The quote_style and charset argumen
- Page 85 and 86:
Query-string encoding The urlencode
- Page 87 and 88:
The comparison operators (=) also w
- Page 89 and 90:
The Levenshtein algorithm calculate
- Page 91 and 92:
The str_repeat( ) function takes a
- Page 93 and 94:
print_r($a);Array ( [0] => Fred [1]
- Page 95 and 96:
The c in strcspn( ) stands for comp
- Page 97 and 98:
These three kinds of patterns can b
- Page 99 and 100:
Subpatterns You can use parentheses
- Page 101 and 102:
Table 4-8. POSIX anchors Anchor Mat
- Page 103 and 104:
Example 4-1. Credit-card validator
- Page 105 and 106:
Character Classes Perl-style regula
- Page 107 and 108:
Trailing Options Perl-style regular
- Page 109 and 110:
A simple use of positive lookahead
- Page 111 and 112:
For example: preg_match('/y.*e$/',
- Page 113 and 114:
Pass an array of strings as subject
- Page 115 and 116:
Quoting for regular expressions The
- Page 117 and 118:
Identifying Elements of an Array Yo
- Page 119 and 120:
array is almost always a programmer
- Page 121 and 122:
Two or more consecutive commas in t
- Page 123 and 124:
echo "true!\n"; } if (array_key_exi
- Page 125 and 126:
EXTR_PREFIX_SAME, which says that t
- Page 127 and 128:
echo "$key is $value\n"; } 0 is spa
- Page 129 and 130:
The default argument, if provided,
- Page 131 and 132:
you need to answer questions like
- Page 133 and 134:
Example 5-3. Sorting arrays (contin
- Page 135 and 136:
Here’s how to randomize the order
- Page 137 and 138:
Sets Arrays let you implement the b
- Page 139 and 140:
Here’s the output from Example 5-
- Page 141 and 142:
Terminology Everyobject-oriented la
- Page 143 and 144:
You can use variable variables with
- Page 145 and 146:
} function set_name ($new_name) { $
- Page 147 and 148:
The object created bythe Person con
- Page 149 and 150:
Example 6-1. Displaying all declare
- Page 151 and 152:
Example 6-2. Object introspection f
- Page 153 and 154:
Here are some sample classes and ob
- Page 155 and 156:
PHP has two hooks for objects durin
- Page 157 and 158:
Example 6-5 shows the file next.php
- Page 159 and 160:
the request contains a blank line,
- Page 161 and 162:
SERVER_NAME The hostname, DNS alias
- Page 163 and 164:
The biggest difference between GET
- Page 165 and 166:
Figure 7-1. The chunkify form and i
- Page 167 and 168:
Example 7-4. Temperature conversion
- Page 169 and 170:
Example 7-6. Multiple selection val
- Page 171 and 172:
Example 7-8. Sticky multivalued che
- Page 173 and 174:
Files are stored in the server’s
- Page 175 and 176:
“me@aol” by requiring an at sig
- Page 177 and 178:
To mark a document as already expir
- Page 179 and 180:
A third technique for maintaining s
- Page 181 and 182:
Example 7-10. Preference selection
- Page 183 and 184:
Session basics To enable sessions f
- Page 185 and 186:
Custom storage By default, PHP stor
- Page 187 and 188:
When a session is completed, the de
- Page 189 and 190:
Chapter 8 CHAPTER 8 Databases PHP h
- Page 191 and 192:
columns, each of which has a name a
- Page 193 and 194:
Figure 8-1. The movie page the data
- Page 195 and 196:
$db = DB::connect($datasource); if
- Page 197 and 198:
string(4) "1962" ["name"]=> string(
- Page 199 and 200:
The executeMultiple( ) method takes
- Page 201 and 202:
echo "$k"; if (is_array($v)) { a_to
- Page 203 and 204:
Two HTML forms are needed to popula
- Page 205 and 206:
Example 8-3. Database connection ab
- Page 207 and 208:
Example 8-4. Backend administration
- Page 209 and 210:
Example 8-5. Adding a business (con
- Page 211 and 212:
Example 8-5. Adding a business (con
- Page 213 and 214:
The business listings page is illus
- Page 215 and 216:
The series of requests sent by the
- Page 217 and 218:
many colors as you need. The latter
- Page 219 and 220:
image-generating function. Example
- Page 221 and 222:
Example 9-4. Adding text to an imag
- Page 223 and 224:
Example 9-6. Displaying vertical Tr
- Page 225 and 226:
Example 9-8. Caching dynamic button
- Page 227 and 228:
You can also take this a step furth
- Page 229 and 230:
For a signed integer, the leftmost
- Page 231 and 232:
True Color Color Indexes The color
- Page 233 and 234:
Chapter 10 CHAPTER 10 PDF Adobe’s
- Page 235 and 236:
Figure 10-1. Hello world in a PDF d
- Page 237 and 238:
Type, Content-Disposition, and Cont
- Page 239 and 240:
Example 10-3. Changing the origin (
- Page 241 and 242:
Example 10-4. Text alignment within
- Page 243 and 244:
Example 10-5. Changing text attribu
- Page 245 and 246:
usr/share/fonts FontAFM LuciduxSans
- Page 247 and 248:
Adding an image to a PDF document i
- Page 249 and 250:
Example 10-8. Nonproportional scali
- Page 251 and 252:
Figure 10-9. A sample path The pdf_
- Page 253 and 254:
The width and height parameters spe
- Page 255 and 256:
Example 10-11. Using a template Th
- Page 257 and 258:
Example 10-12. Using bookmarks and
- Page 259 and 260:
Example 10-13. Specifying a link (c
- Page 261 and 262:
Figure 10-16. Closed note The conte
- Page 263 and 264:
In HTML, you often have an open tag
- Page 265 and 266:
Example 11-1. Generating an XML doc
- Page 267 and 268:
The end element handler is called w
- Page 269 and 270:
If your external entity reference h
- Page 271 and 272:
characters outside the target encod
- Page 273 and 274:
XML_ERROR_BAD_CHAR_REF XML_ERROR_BI
- Page 275 and 276:
Figure 11-2. Book details comment).
- Page 277 and 278:
Example 11-10. bookparse.xml (conti
- Page 279 and 280:
Example 11-12. News XSL transform
- Page 281 and 282:
more information). The xmlrpc exten
- Page 283 and 284:
equest, but it doesn’t know how t
- Page 285 and 286:
Chapter 12 CHAPTER 12 Security PHP
- Page 287 and 288:
These directives ensure that PHP er
- Page 289 and 290:
Restrict Filesystem Access to a Spe
- Page 291 and 292:
function or PHP’s copy( ) functio
- Page 293 and 294:
• Any system call (through functi
- Page 295 and 296:
You can globally disable particular
- Page 297 and 298:
Chapter 13 CHAPTER 13 Application T
- Page 299 and 300:
user.template. It uses the {DESTINA
- Page 301 and 302:
{ARTICLE} might be useful, as it wo
- Page 303 and 304:
} ob_start('rewrite'); ?> Visit our
- Page 305 and 306:
To turn off error reporting entirel
- Page 307 and 308:
Example 13-5. Log-rolling error han
- Page 309 and 310:
Before you begin optimization, ask
- Page 311 and 312:
changes you make to your code as yo
- Page 313 and 314:
• Only include or require files t
- Page 315 and 316:
MySQL replication Sometimes the dat
- Page 317 and 318:
Chapter 14 CHAPTER 14 Extending PHP
- Page 319 and 320:
examples, and you are strongly enco
- Page 321 and 322:
int Integer/long long Same as int a
- Page 323 and 324: zend_module_entry rot13_module_entr
- Page 325 and 326: for(i=0, ch=arg; i= 'A')&&(*ch
- Page 327 and 328: if (extension_loaded($module)) { $s
- Page 329 and 330: SWF_DIR=$i AC_MSG_RESULT(found in $
- Page 331 and 332: If you compile the Apache module ve
- Page 333 and 334: For example: zval **old, *new; *new
- Page 335 and 336: The value returned from a PHP funct
- Page 337 and 338: A More Complex Example Here’s an
- Page 339 and 340: Table 14-4. RETURN-related convenie
- Page 341 and 342: * ... */ }; PHP_MINIT_FUNCTION(foo)
- Page 343 and 344: using SEPARATE_ZVAL( ), initializes
- Page 345 and 346: The struct looks like this in the p
- Page 347 and 348: zend_hash_update(&EG(symbol_table),
- Page 349 and 350: Resources A resource is a generic d
- Page 351 and 352: Chapter 15 CHAPTER 15 PHP on Window
- Page 353 and 354: 3. Windows 95/98/Me: the Windows sy
- Page 355 and 356: Then explicitly load the module wit
- Page 357 and 358: un under IIS, you will need to reim
- Page 359 and 360: External Commands PHP uses the defa
- Page 361 and 362: This creates a reference (VT_BYREF)
- Page 363 and 364: Figure 15-3. Gleaning syntax from W
- Page 365 and 366: Now we can complete the invoice wit
- Page 367 and 368: multiple Workbooks, each of which c
- Page 369 and 370: Example 15-4. Querying Excel via OD
- Page 371 and 372: • Applications that want to use t
- Page 373: Example 15-5. Add new phone number,
- 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)