PHP 5 Advanced: Visual QuickPro Guide (ISBN 0-321-37601-3) © … · 2009. 6. 9. · ; (semicolon),...

24
; (semicolon), 111 :: (scope resolution) operator, 289–293 * (asterisk), 399, 541 ` (backticks), 415 // (comment symbol), 44–46 @ (error suppression operator), 314 | (or symbol), 541 % (percent sign), 37, 42 + (plus sign), 541 ? (question mark), 541 “ (quotation marks), 284, 444, 445–455 ‘ (quote marks), 444, 445–455 +/- (sign specifier), 37 / (slash), 189 A a mode, 374 a+ mode, 374 abstract classes, 300–307 abstract keyword, 300 abstract methods, 300–307 abstraction, 234 access control, 234, 281–288 ActiveXObject() function, 492–494 addAttachment() method, 478 addAttribute() method, 556 addBcc() method, 470 addCc() method, 470 addChild() method, 556 addHTMLImage() method, 476–477, 479 add_item() method, 333–334, 344 addresses table, 182 addRule() method, 461–467 addUser() function, 149 addUser() method, 145 Advanced Encryption Standard (AES), 158 advcheckbox element type, 456 AES (Advanced Encryption Standard), 158 Ajax, 481–528 considerations, 528 database creation, 485–486 described, 481–482 example, advanced, 506–522 example, simple, 484–505 GET requests, 495, 526 HTTP status codes, 496 introduction to, 482–483 populating database, 486 POST requests, 523, 526 server requests, 482, 496 Web browser support, 482–528 XML and, 481, 483 Ajax applications creating HTML for, 500–503, 520–522 creating PHP script for, 487–490, 507–512 debugging, 523–528 testing, 504–505 testing PHP script, 491, 524–527 Web browser support, 482–528 writing JavaScript for, 492–499, 513–519 Ajax model, 482 Ajax transactions, 482, 483, 494 alignment specifier, 37 alphabetical sorts, 2–7 569 Index i Index

Transcript of PHP 5 Advanced: Visual QuickPro Guide (ISBN 0-321-37601-3) © … · 2009. 6. 9. · ; (semicolon),...

  • ; (semicolon), 111:: (scope resolution) operator, 289–293* (asterisk), 399, 541` (backticks), 415// (comment symbol), 44–46@ (error suppression operator), 314| (or symbol), 541% (percent sign), 37, 42+ (plus sign), 541? (question mark), 541“ (quotation marks), 284, 444, 445–455‘ (quote marks), 444, 445–455+/- (sign specifier), 37/ (slash), 189

    Aa mode, 374a+ mode, 374abstract classes, 300–307abstract keyword, 300abstract methods, 300–307abstraction, 234access control, 234, 281–288ActiveXObject() function, 492–494addAttachment() method, 478addAttribute() method, 556addBcc() method, 470addCc() method, 470addChild() method, 556addHTMLImage() method, 476–477, 479add_item() method, 333–334, 344addresses table, 182

    addRule() method, 461–467addUser() function, 149addUser() method, 145Advanced Encryption Standard (AES), 158advcheckbox element type, 456AES (Advanced Encryption Standard), 158Ajax, 481–528

    considerations, 528database creation, 485–486described, 481–482example, advanced, 506–522example, simple, 484–505GET requests, 495, 526HTTP status codes, 496introduction to, 482–483populating database, 486POST requests, 523, 526server requests, 482, 496Web browser support, 482–528XML and, 481, 483

    Ajax applicationscreating HTML for, 500–503, 520–522creating PHP script for, 487–490, 507–512debugging, 523–528testing, 504–505testing PHP script, 491, 524–527Web browser support, 482–528writing JavaScript for, 492–499, 513–519

    Ajax model, 482Ajax transactions, 482, 483, 494alignment specifier, 37alphabetical sorts, 2–7

    569

    Indexi

    Index

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 569

  • ASCII integer, 37asterisk (*), 399, 541asXML() method, 561asynchronous behavior, 483Asynchronous JavaScript and XML. See AjaxAtom format, 568attach() method, 395attachments, email, 469, 478, 479attributes. See also specific attributes

    class, 235, 236, 244description, 542empty elements, 536–539format of, 541–542static, 294–299values, 541–542visibility of, 281vs. variables, 236XML, 536–539

    Auth class, 144–156auth element, 470Auth package, 143–156Auth type, 144authentication. See also passwords; security

    custom, 151–156database-driven, 144HTTP, 157, 372logout feature, 154Mail_Mime package, 469MySQL, 145–149, 152optional, 150PEAR Auth package, 143–156simple, 144–150Web site, 143–156

    authentication system, 143–156Auth_HTTP authorization, 157autocomplete element type, 456autoload() function, 260–262, 306autoloading classes, 260–262autoloading functions, 306

    Bb mode, 374backticks (`), 415backups, database, 375–384base class, 265

    alphanumeric rule, 462Alternative PHP Cache (APC), 80Amazon, 530& entity, 536Andrews, Tjobbe, 190ANY type, 541Apache server, 424APC (Alternative PHP Cache), 80API (application programming interface), 232' entity, 536application programming interface (API), 232applications

    Ajax. See Ajax applicationscommand-line, 435, 437PuTTY, 422running through URLs, 524shopping cart, 212–223SSH, 422templates for, 190–196Terminal, 400testing, 504–505Web. See Web applications

    applyFilter() method, 461–463, 468$argc array, 432arguments

    command-line, 432–436constructors, 251filter, 137methods, 235, 240, 300, 301sessions, 84stored functions, 110

    $argv array, 432arrays. See also specific arrays

    adding tasks to, 23database-driven, 8–17default form values, 461filters, 142form validation, 131, 461–465multidimensional, 2–24nested structure, 8–17serialized, 89sorting, 2–7two-dimensional, 2

    array_sum() function, 303ASCII characters, 38

    570

    Inde

    xIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 570

  • cart class, 340–346catch block, 311, 316, 319catch statement, 310catching exceptions, 310–316categories

    browsing by, 199–204no products in, 211printing as links, 194validating, 202

    categories table, 172, 176–178, 193, 194category ID, 194, 200–204category page, 200–204CDATA type, 542CGI (Common Gateway Interface), 418, 427character data, 554Character Type functions, 127characters

    ASCI, 38, 499control, 127escaped, 189, 499formatting, 37–38length, 510letters only, 127lowercase, 127newline, 124, 423, 427, 438out-of-range, 499printable, 127special, 536uppercase, 127UTF-8, 499white space, 127XML, 549

    check boxes, 32–33, 35, 456checkAuth() method, 145, 154checkbox element type, 456checkdate() function, 126, 132checkout systems, 224–232check_url() function, 359, 362check_urls() function, 361check_username() function, 498, 502, 505child classes, 264–270chmod utility, 431ciphers, 158class constants, 295class definition files, 261–262

    base64_decode() function, 157, 166base64_encode() function, 157, 162base64_encode() version, 163BASE_URI constant, 54BASE_URL constant, 54BEGIN keyword, 111Benchmark package, 444–456benchmark timers, 445–450benchmarking, 444–456benchmarking functions, 451–456Benchmark_Iterate class, 451, 455binary data, 157, 380binary files, 382binary integer, 37binary mode, 374binary numbers, 37–38Boolean value, 84, 466bots, 135browsers. See Web browsersbrowsing, by category, 199–204button element type, 456buttons

    associating keys with, 398calculator, 386–396, 398radio, 456reset, 456submit, 456, 457, 460, 516, 520

    Ccache-control directives, 75Cache-Control header, 75, 79caching

    APC, 80browsers, 74–80, 526considerations, 80in proxy servers, 74server-side, 80session, 80in Web pages, 74–80

    calculate() function, 387–388, 392calculator example, 386–398call() method, 280call_this_function() function, 495captcha test, 135carriage returns (\r), 124

    571

    IndexIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 571

  • client URL (cURL) utility, 80, 368–372, 399, 401

    client/server model, 482client/server performance, 80client-side validation, 462, 464, 465–466“close” function, 84close() method, 326close_session() function, 94closing brackets, 46code. See also scripts

    benchmarking, 444, 445–450comments, 44–46consistency and, 47indenting, 48structure, 47–48style, 47–48testing snippets of, 422–423updates to, 46white space in, 44, 48

    code blocks, 423code snippets, 422–423colors table, 172, 176, 179columns, 83, 98–100, 102, 413COM (Component Object Module), 404–415COM classes, 414, 415com() function, 404COM objects, 410com_exception class, 414Command Line Interface. See CLIcommands. See also specific commands

    running on server, 125, 415SQL, 98, 173, 486variables and, 125

    comment symbol (//), 44–46comments

    errors and, 287filtering, 140–142regular expression patterns, 126, 132writing, 44–46XML documents, 533

    Common Gateway Interface (CGI), 418, 427compare rule, 462, 465Component Object Module (COM), 404–415compression, 80, 374–384CONCAT_WS() function, 107

    class keyword, 237classes. See also specific classes

    abstract, 300–307attributes, 235, 236, 244autoloading, 260–262base, 265child, 264–270COM, 414, 415CSS, 362, 550–554defining, 235–239derived, 265described, 234, 235inheriting, 266–270members of, 265methods within, 235names, 235, 243, 262network-related, 354OOP. See OOP classesparent, 264–270shopping cart, 328–346static class attributes, 294–299subclass, 265, 276, 288, 298superclass, 265visibility, 265

    clausesIN, 220else, 167, 334, 442, 490else if, 494“out,” 18RETURNS, 111WHERE, 106

    clear() function, 396CLI (Command Line Interface), 417–442

    arguments, 432–436errors, 431, 435, 436, 441–442running scripts from, 424–431testing code snippets, 422–423testing installation of, 418–422uses for, 417, 423vs. CGI, 418

    CLI applications, 435, 437CLI php.ini file, 424CLI scripts

    creating, 424–427running, 428–431

    572

    Inde

    xIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 572

  • counter, 116, 120, 121, 295–298, 427count_to_100() function, 25CREATE TABLE command, 10, 151–152,

    174–178credit card processing, 171, 224–232cron utility, 399–401crontab file, 399–401crontab format, 399cryptType function, 151CSS classes, 362, 550–554CSS files, 58, 190ctype_ functions, 127ctype_alnum() function, 131ctype_digit() function, 132cURL (client URL) utility, 80, 368–372,

    399, 401curl_errno() function, 372curl_error() function, 372curl_exec() command, 369curl_getinfo() function, 372curl_init() function, 368, 370CURLOPT_POSTFIELDS option, 370curl_setopt() function, 368curly braces, 48custom authentication, 151–156customers table, 171, 174, 182

    Ddata

    binary, 157, 380encrypting/decrypting. See encryptionescaping, 189, 468importing, 98processing in forms, 466–468reading from Web sites, 348–354session, 82–95, 125trimming, 461validating. See validation

    data source name (DSN), 144database connections

    closing, 195, 370–372, 490configuration file, 184–186errors, 14, 189, 379, 489establishing, 184, 189, 495, 498file compression and, 378–379

    conditionalscommenting, 46nested, 310processing form data, 466, 468session handlers, 92switch, 64–65, 238, 324validation, 202–204

    configuration filescreating, 183–189e-commerce application, 183–189index pages, 197–198Web applications, 50–57

    connections. See database connectionsconnect_simple() method, 386, 390, 398Console_Getargs package, 436Console_Getopt package, 436const keyword, 295constants

    accessing, 295BASE_URI, 54BASE_URL, 54class, 295DB, 54, 187“magic,” 465server-specific, 53–54, 187STDIN, 437–439, 442values, 295

    construct() method, 251–252, 255, 271constructors

    arguments, 251calling, 255creating, 251–255declaring, 255default, 255described, 251Exception, 318, 327inheritance, 271–275subclass, 272–275using, 252–256vs. destructors, 256

    containers, 385, 394content modules, 66–69contingencies, 45control characters, 127cookies, 157, 159–163, 372

    573

    IndexIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 573

  • products from shopping cart, 219, 223,335–336

    sessions, 89delimiters, 111derived class, 265design patterns, 235destroy events, 397destruct() function, 256, 258destructors

    creating, 256–259described, 256inheritance, 271, 274Java and, 259OOP, 256–259vs. constructors, 256

    directoriesbackup, 376–383permissions, 378, 380–381session, 82, 125site structure, 48temporary, 82writable, 378

    display() method, 445, 466–468display windows, 391, 395, 396display_cart() method, 346distance calculations, 103–109dl() function, 391DMCinsights.com, 170do() function, 289do() method, 244document modeling, 540–541Document Object Model. See DOMDocument Type Definitions (DTDs), 540–547Dojo software, 518DOM (Document Object Model), 496, 548DOM parsers, 548, 556–561drop-down menus, 15, 16DSN (data source name), 144DTDs (Document Type Definitions), 540–547

    EeBay, 530echo() function, 37, 398, 447–454, 475echo() statement, 423ECMAScript language, 494

    RSS feeds and, 565secure, 422

    database creationAjax example, 485–486e-commerce example, 171–182multidimensional arrays, 10–11

    database files, 57, 187database-driven arrays, 8–17databases. See also records; tables

    adding tasks to, 12–18advanced concepts, 81–122backing up, 375–384compression, 374–384connections. See database connectionscreating. See database creationescaping data for, 468names, 375normalization, 172, 173, 176populating, 486selecting, 174storing sessions in, 82–95zip code, 96–109

    date element type, 456date() function, 423, 567date_added attribute, 9date_completed attribute, 9day menu, 456DB constant, 54, 187DB container, 151debug mode, 187–188$debug variable, 54debuggers, 527debugging. See also errors

    Ajax applications, 523–528error messages associated with, 188JavaScript, 523–528selecting mode, 187

    debugging level, 54decimal point, 390, 393, 396DECLARE statement, 110decrypting data, 164–167DELETE query, 89delete_item() method, 335–336deleting

    objects, 240, 242, 249, 259

    574

    Inde

    xIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 574

  • encapsulation, 234, 242, 288encodeURIComponent() method, 499encryption, 157–167

    AES, 158MCrypt, 157–167passwords, 149, 154

    END keyword, 111entities, 536–539EOD delimiter, 32EOT delimiter, 32error handling, 55, 57, 188–189, 310, 327error messages, 55–56, 188, 324, 464error reporting, 125error suppression operator (@), 314error_log() function, 56, 188errors. See also debugging

    CLI, 431, 435, 436, 441–442COM, 410, 413comments, 287connection, 14, 189, 379, 489cURL, 370, 372emailing, 53, 56, 184exception, 310–316file open, 314handling, 55, 57, 188, 310, 327HTML, 464JavaScript, 464, 527live sites, 125OOP, 234, 310, 327parse, 32, 422PEAR packages, 446, 461, 464printing, 56unable to open URL, 352validation, 133variable names and, 196

    escape() method, 499escaped characters, 189escapeshellarg() function, 125, 415escapeshellcmd() function, 125, 415escaping data, 468eval() function, 513, 517, 519event-based parsers, 548events

    destroy, 397form-related, 456

    e-commercecheckout systems, 224–232configuration file, 183–189credit card processing, 171, 224–232database creation, 171–182overview, 170payments, 232showing products online, 205–211templates, 190–196

    e-commerce examplebrowse feature, 199–204index page, 197–198product catalog, 205–211shopping cart, 212–223

    e-commerce sites, 170, 174element type symbols, 541element types, 541elements

    empty, 536–539HTML, 456, 457JavaScript, 500password, 460XML, 530, 536–539

    else clause, 167, 334, 442, 490else if clause, 494email

    attachments, 469, 478, 479avoiding abuse of, 124carbon copies, 470HTML, 469–479images, 476–479passwords, 131plain text, 469–470, 474–479

    email address element, 458email addresses

    carbon copies, 470e-commerce sites, 174rules, 462, 464, 465validating, 131, 462

    email rule, 462, 464emailing errors, 53, 56, 184emailorblank rule, 462empty elements, 536–539EMPTY type, 541

    575

    IndexIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 575

  • file_exists() function, 325FileIO class, 326filename rule, 462filenames, 125, 462, 545files

    backup, 375–384binary, 382class definition, 261–262closing, 316, 374compressing, 374–384configuration. See configuration filesCSS, 58, 190database, 57, 187FTP, 368, 372help, 418, 420, 421, 475included, 125modification date, 423moving, 125names, 125, 462, 545opening, 316, 348, 374, 380, 426permissions, 314, 315, 348, 381PHP, 199, 400–401php.ini, 406, 424read/write modes, 374–375time modified, 378Word, 404XML. See XML documents

    $filter argument, 137filter_has_var() function, 142filtering

    comments, 140–142form data, 461–465variables, 136–142

    filter_input() function, 137filter_list() function, 137filters

    array of, 142listed, 137PECL Filter, 136–142

    filter_var() function, 137filter_var_array() function, 142final function, 279Firefox browser, 493, 526, 527, 531, 565flag variables, 202floating-point numbers, 37, 38, 98, 438–442

    JavaScript, 500user, 386, 397

    Excel class, 415Excel spreadsheets, 405, 406–415Exception class, 311, 317–327Exception class methods, 311Exception constructor, 318, 327exception handling, 310, 312–316, 320exceptions

    catching, 310–316, 414COM, 414errors, 310–316throwing, 310–316vs. error handling, 310

    exec() function, 415execution tendencies, 444Expat parser, 548, 549–551, 555Expires header, 75, 79extends statement, 266Extensible Markup Language. See XMLExtensible Stylesheet Language

    Transformation (XSLT), 555extensions, 48, 61, 64, 424, 440

    F-f flag, 428f mode, 374factory() method, 470–471, 474fclose() function, 316, 352, 360, 383fgetc() function, 442fgetcsv() function, 352, 353, 442fgets() function, 437fields

    comments, 141name, 140, 141, 464password, 465required, 465, 484textarea, 456timestamp, 78

    file element type, 456file extensions, 48, 61, 64, 424, 440file() function, 426file open modes, 374file pointer, 355file upload prompt, 456

    576

    Inde

    xIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 576

  • call_this_(), 495Character Type, 127checkdate(), 126, 132check_url(), 359, 362check_urls(), 361check_username(), 498, 502, 505clear(), 396close_session(), 94com(), 404commenting, 45CONCAT_WS(), 107count_to_100(), 25cryptType, 151ctype_alnum(), 131ctype_digit(), 132curl_errno(), 372curl_error(), 372curl_getinfo(), 372curl_init(), 368, 370curl_setopt(), 368date(), 423, 567destruct(), 256, 258dl(), 391do(), 289echo(), 37, 398, 447–454, 475error_log(), 56, 188escapeshellarg(), 125, 415escapeshellcmd(), 125, 415eval(), 513, 517, 519exec(), 415fclose(), 316, 352, 360, 383fgetc(), 442fgetcsv(), 352, 353, 442fgets(), 437file(), 426file_exists(), 325filter_has_var(), 142filter_input(), 137filter_list(), 137filter_var(), 137filter_var_array(), 142final, 279fopen(). See fopen() functionfscanf(), 42, 437, 438, 442fsockopen(), 355

    folders, 48, 54fopen() function

    CLI scripts, 426file compression, 374, 380, 383–384opening files, 316, 348, 374, 426, 554Web site access, 348

    fopen() method, 362fopen() mode, 316for loop, 73, 122, 519foreach loop, 362, 413, 427, 560foreign keys, 9, 175, 176, 182formatting items

    characters, 37–38with CSS classes, 550–554numbers, 37–38strings, 38XML output, 550–554

    forms. See also HTML formscredit card processing, 229–231default values, 461filtering data, 461–465hidden input, 131login functionality, 144–156logout functionality, 93–95, 154processing data in, 466–468registration. See registration formsrules, 461–467validating, 126–135, 131, 461–465

    fragment value, 356Frameworks, 72fscanf() function, 42, 437, 438, 442fsockopen() function, 355fsockopen() method, 356–362FTP files, 368, 372FTP port, 355functions

    ActiveXObject(), 492–494addUser(), 149array_sum(), 303autoload(), 260–262, 306autoloading, 306base64_decode(), 157, 166base64_encode(), 157, 162benchmarking, 451–456calculate(), 387–388, 392

    577

    IndexIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 577

  • popen(), 415printf(), 37–38, 398, 441print_r(), 6, 93readgzfile(), 375recursive, 18–24references and, 30registerRule(), 465require_once(), 241, 243return_distance(), 114, 507rtrim(), 164scanf(), 42session, 84–90session.auto_start, 90session_cache_limit(), 80session_destroy(), 89session_save_path(), 82session_set_save_handler(), 84, 90, 91session_start(), 90, 93session_write_close(), 91, 94, 95set_display(), 391–392, 396setlocale(), 127setMarker(), 445–449set_number(), 392–393, 396set_operator(), 396set_time_limit(), 362, 406–407SHA(), 174, 485shell_exec(), 368, 415show_login_form(), 154show_stores(), 517–519signature, 280sleep(), 269sprintf(), 38, 39–42, 490srand(), 158stored, 110–115strcasecmp(), 6, 352strcmp(), 3strip_tags(), 125strtolower(), 553system(), 415trigger_error(), 189trim(), 462uasort(), 3, 6uksort(), 3UNIX_TIMESTAMP(), 78unserialize(), 343

    fwrite(), 314, 355, 380getAuthData(), 151, 156get_class(), 270gethostbyaddr(), 367gethostbyname(), 363gethostbynamel(), 367get_parent_class(), 270get_perimeter(), 246get_stores(), 516, 521grade_sort(), 28gzfile(), 375gzopen(), 374, 377, 380gzwrite(), 380handle_character_data(), 554handle_check(), 498, 499handle_open_element(), 553handle_stores(), 517, 518header(), 74–76htmlentities(), 372, 567include_once(), 241is_a(), 284isset(), 560is_subclass_of(), 284is_writable(), 378mail(), 124, 469–471make_list(), 23, 24, 35MCRYPT_DEV_RANDOM, 158mcrypt_enc_get_iv_size(), 158mcrypt_end_get_key_size(), 163mcrypt_module_open(), 158MCRYPT_RAND, 158MD5(), 149, 158–161, 160, 163mdecrypt_generic(), 164, 166my_error_handler(), 189mysqli_real_escape_string(), 88, 189,

    468, 490names, 243name_sort(), 26number(), 228ob_gzhandler(), 80open(), 523parse_url(), 355–356passthru(), 415pclose(), 415performance, 452–455

    578

    Inde

    xIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 578

  • Google, 530grade_sort() function, 28graphical calculator example, 386–398group element type, 456> entity, 536GTK+ (GIMP Tool Kit), 385–398GTK home page, 385GtkWindow() widget, 394gzfile() function, 375gzopen() function, 374, 377, 380gzwrite() function, 380

    Hh mode, 374handle_character_data() function, 554handle_check() function, 498, 499handle_open_element() function, 553handle_stores() function, 517, 518header element type, 456header() function, 74–76header types, 74–75, 458headers() method, 470HelloWorld class, 237–244HelloWorld example, 237–244help files, 418, 420, 421, 475heredoc syntax, 31–36, 339, 445–451hexadecimal integer, 37hexidecimal numbers, 127hidden element type, 456hidden input, 131, 456hidden values, 135hiddenselect element type, 456hide() method, 397hierselect element type, 456hinting, type, 319home page, 69, 197–198host value, 356HTML

    Ajax applications, 500–503, 520–522clearing, 125entities, 539errors, 464vs. XML, 530

    HTML elements, 456, 457

    usort(), 3, 6vprintf(), 42write_session(), 94xml_parse(), 549xml_parse_create(), 549, 554xml_parse_free(), 549xml_set_character_data_handler(), 549xml_set_element_hander(), 549

    fwrite() function, 314, 355, 380

    Ggarbage collection function, 89Garrett, Jesse James, 483general_widgets table, 173, 177–180get() method, 451, 470get_ methods, 250GET requests, 495, 526get_area() method, 248, 301, 304getAuth() method, 150getAuthData() function, 151, 156get_class() function, 270getCode() method, 311get_count() method, 298getFile() method, 311gethostbyaddr() function, 367gethostbyname() function, 363gethostbynamel() function, 367getMessage() method, 311, 315get_parent_class() function, 270get_perimeter() function, 246get_perimeter() method, 304getProfiling() method, 445getRecord() method, 364get_stores() function, 516, 521getTrace() method, 311getTraceAsString() method, 311GIMP (GNU Image Manipulation

    Program), 385GIMP Tool Kit (GTK+), 385–398global statement, 30global variables, 25, 55, 137, 391–394Gnope Web site, 385GNU Image Manipulation Program

    (GIMP), 385

    579

    IndexIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 579

  • inheritance theory, 274innerHTML property, 496, 498, 499InnoDB storage engine, 175, 176, 182input

    hidden, 131, 456image, 456password, 456standard, 437–439, 442text, 456user, 438–442

    instanceof keyword, 284INT keyword, 102integers, 37, 38interfaces, 307Internet Explorer browser, 74, 492, 526,

    527, 531Internet service provider (ISP), 363IP addresses, 356–367IP geolocation, 363is_a() function, 284ISBN numbers, 182is_empty() method, 333ISP (Internet service provider), 363isset() function, 560is_subclass_of() function, 284is_writable() function, 378Iterate class, 451, 454

    JJava language, 494JavaScript

    Ajax applications, 482, 492–499, 513–519asynchronous transactions and, 483clearing, 125errors/debugging, 464, 523–528

    JavaScript alerts, 519, 525JavaScript console, 527JavaScript debugger, 527JavaScript events, 500JavaScript Object Notation (JSON), 506–521JavaScript-enhanced text boxes, 456joins, 100, 102JSON (JavaScript Object Notation), 506–521

    HTML email, 469–479. See also emailHTML forms. See also forms

    Ajax applications, 501–503, 520–522creating, 134, 457–460, 501–503credit card processing, 229–231elements, 457hidden values in, 135HTML_QuickForm package, 456–468shopping cart, 337

    HTML tags, 372, 496, 530HTML templates, 58–61HTML_AJAX package, 518htmlentities() function, 372, 567HTML_QuickForm class, 456, 457, 459HTML_QuickForm package, 456–468HTTP authentication, 157, 372HTTP status codes, 356, 360, 361, 496Huffman-only compression, 374

    IID type, 542IIS (Internet Information Server), 424image element type, 456image input, 456images

    directory for, 48GD library, 135HTML email, 476–479as input, 456

    IMAP port, 355img tag, 476–478, 561importing data, 98IN clause, 220included files, 125include_once() function, 241index page, 62–65, 197–198indexes, 10, 99, 102, 519infinite loop, 18inheritance

    from classes, 266–270constructors, 271–275described, 264, 266destructors, 271, 274terminology, 265

    580

    Inde

    xIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 580

  • MySQL Administrator, 112–115remote server connections, 422running scripts, 424–425, 431Terminal application, 400, 421testing CLI installation on, 421

    macros, 415“magic” constants, 465Magic Quotes, 189mail. See emailMail class, 469–471mail() function, 124, 469–471Mail_Mime class, 469, 471, 474Mail_Mime package, 469–479main() method, 397main module, 66–69main page, 62–65main_quit() method, 397make_list() function, 23, 24, 35markup language, 530, 531max-age directive, 75maxfilesize rule, 462maxlength rule, 462MCrypt application, 157–167MCrypt library, 157MCRYPT_DEV_RANDOM function, 158mcrypt_enc_get_iv_size() function, 158mcrypt_end_get_key_size() function, 163mcrypt_module_open() function, 158MCRYPT_RAND function, 158MD5() function, 149, 158–161, 163MD5() method, 154mdecrypt_generic() function, 164, 166member access, 281–288META tags, 80metadata, 171, 175meta-properties, 45methods

    abstract, 300–307access control, 281–288accessibility of, 281–288addAttachment(), 478addAttribute(), 556addBcc(), 470addCc(), 470addChild(), 556

    Kkeys

    associating buttons with, 398foreign, 9, 175, 176, 182primary, 9, 83, 88, 149, 173–178

    keywords, 110, 300

    Llabels, 395, 456Last-Modified header, 74–75, 79LDAP port, 355lettersonly rule, 462libmcrypt, 157libraries

    GD, 135MCrypt, 157PHP, 345SimpleXML, 557SPL, 345zlib, 374–376

    libxml parser, 548link element type, 456links

    categories as, 194“Log Out,” 93–95product catalog, 205–211to shopping cart, 210

    LOAD DATA INFILE query, 98local variables, 110login functionality, 144–156logout functionality, 93–95, 154logout() method, 154loops

    for, 73, 122, 519foreach, 362, 413, 427, 560infinite, 18parsed files, 554, 559while, 121, 413, 511

    < entity, 536Lynx browser, 399

    MMac OS X

    binary files and, 382

    581

    IndexIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 581

  • open(), 495, 513, 523overloading, 280overriding, 277–281print_var(), 284, 285, 288run(), 455send(), 523set_, 250setAdvancedSecurity(), 156setAuthData(), 156set_default_size(), 394set_size(), 245, 247, 248, 255set_title(), 394show(), 397show_all(), 397start(), 154static, 295–299testing, 455timeElapsed(), 445, 449toString(), 311, 318update_item(), 333, 335, 345visibility of, 281–288

    Microsoft Script Debugger, 527Microsoft.XMLHTTP object, 494mimetype rule, 462minlength rule, 462modularity, 49–73, 234month menu, 456Msxml2.XMLHTTP object, 494multidimensional arrays, 2–24must-revalidate directive, 75my_error_handler() function, 189MySQL

    authentication, 145–149, 152connecting to. See database connectionsdatabase access, 83database creation, 10–11distance calculation, 104–109errors. See errorsimporting data, 98joins, 102stored functions, 110–115versions, 81, 183

    MySQL Administrator, 112, 113mysql client, 111MySQL GUI Tools package, 112

    addHTMLImage(), 476–477, 479add_item(), 333–334, 344addRule(), 461–467addUser(), 145applyFilter(), 461–463, 468arguments, 235, 240, 300, 301asXML(), 561attach(), 395call(), 280checkAuth(), 145, 154within classes, 235close(), 326connect_simple(), 386, 390, 398construct(), 251–252, 255, 271delete_item(), 335–336display(), 445, 466–468display_cart(), 346do(), 244encodeURIComponent(), 499escape(), 499Exception class, 311factory(), 470–471, 474fopen(), 362fsockopen(), 356–362get(), 451, 470get_area(), 248, 301, 304getAuth(), 150getCode(), 311get_count(), 298getFile(), 311getMessage(), 311, 315get_perimeter(), 304getProfiling(), 445getRecord(), 364getTrace(), 311getTraceAsString(), 311headers(), 470hide(), 397is_empty(), 333logout(), 154main(), 397main_quit(), 397MD5(), 154names, 243OOP, 277–281, 300–307

    582

    Inde

    xIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 582

  • SKU, 172, 178, 182type specifiers, 37

    numeric rule, 462numeric sorts, 2–7

    Oob_gzhandler() function, 80Object Browser, 405object type hinting, 319object-oriented programming. See OOPobjects

    ActiveXObject, 492–494COM, 410creating, 240–243, 492deleting, 240, 242, 249, 259Microsoft.XMLHTTP, 494Msxml2.XMLHTTP, 494.NET, 415OOP, 234$this attribute, 244–250XMLHttpRequest, 492–496

    octal integer, 37onblur() event, 500onchange() event, 500onclick() event, 521onfocus() event, 500onload() event, 500onreadystatechange property, 495onreset() event, 500onsubmit() event, 500OOP (object-oriented programming),

    233–346abstract classes/methods, 300–307access control, 281–288advanced techniques, 263–308autoloading classes, 260–262cart class, 340–346constructors, 251–255creating objects, 240–243defining classes, 235–239design patterns, 235destructors, 256–259errors, 234, 310, 327exceptions. See exceptionsinheritance. See inheritance

    MySQL Improved extension, 14, 183, 489MySQL users, 145mysqli_real_escape_string() function, 88,

    189, 468, 490

    N\\n (newline), 124, 423, 427, 438name attribute, 288name element, 458name fields, 140, 464name_sort() function, 26nested items

    conditionals, 310tasks, 19, 24to-do lists, 8–17XML elements, 532, 534

    .NET objects, 415Net_Geo PEAR class, 363Net_GeoIP PEAR class, 363networking, 347–372

    cURL utility, 368–372IP geolocation, 363–367PEAR and, 354sockets, working with, 355–362Web site access, 348–354

    network-related classes, 354new keyword, 240newline (\n), 124, 423, 427, 438NMTOKEN type, 542NMTOKENS type, 542no-cache directive, 75nodes, 499nonzero rule, 462nopunctuation rule, 462normalization, 172, 173, 176NULL values, 99, 176, 510number() function, 228numbers

    binary, 37–38character type functions, 127floating-point, 37–38, 98, 438–442formatting, 37–38hexidecimal, 127integers, 37–38ISBN, 182

    583

    IndexIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 583

  • PHP, 548, 550–555SAX, 548, 561SimpleXML, 556–561

    parse_url() function, 355–356parsing XML, 548–561pass value, 356passthru() function, 415password element type, 456password elements, 460password field, 465password input, 456passwords. See also authentication

    email, 131encrypted, 149, 154input, 456rules, 465validating, 131, 465

    path value, 356paths, 82, 359patterns, design, 235payments, credit card, 224–232PayPal, 530#PCDATA type, 541pclose() function, 415pcntl (process control) extension, 440PEAR (PHP Extension and Application

    Repository), 443–479errors, 446, 461, 464installing, 446networking and, 354

    PEAR HTML_AJAX package, 518PEAR Net_Geo class, 363PEAR packages

    Auth, 143–156Benchmark, 444–456Cache/Cache_Lite, 80Console_Getargs, 436Console_Getopt, 436described, 443HTML_AJAX, 518HTML_QuickForm, 456–468installing, 446Mail_Mime, 469–479Text_CAPTCHA, 135

    PECL (PHP Extension Code Library), 80

    object type hinting, 319overriding methods, 277–281performance and, 234pros and cons, 234real-world uses of, 309–346scope resolution (::) operator, 289–293shopping cart class, 328–339static class attributes, 294–299theories, advanced, 264–265theories, basic, 233–262$this attribute, 244–250versions, 233visibility, 281–288

    OOP classesabstract, 300–307autoloading, 260–262considerations, 234defining, 235–239

    open() function, 523“open” function, 84open() method, 495, 513, 523Open Source Web Design, 58, 190$operator variable, 392–393operators, 398optimizing joins, 102or symbol (|), 541Oracle database, 83order_contents table, 172, 173, 175orders table, 171, 172, 175“out” clause, 18overloading methods, 280overriding methods, 277–281

    Ppadding specifier, 37page caching, 80parent classes, 264–270parent keyword, 289parent_id attribute, 9parent_id value, 10, 14parse errors, 32, 422parsers

    described, 548DOM, 548, 556–561Expat, 548, 549–551, 555

    584

    Inde

    xIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 584

  • POST data, 370, 372POST method, 135POST requests, 523, 526PostgreSQL database, 83Pragma header, 75precision specifier, 37primary keys, 9, 83, 88, 149, 173–178printf() function, 37–38, 398, 441printing

    array items, 21categories as links, 194error messages, 56items in cart, 222with printf(), 37–38, 398, 441with print_r(), 6, 93with print_var(), 284, 285, 288with sprintf(), 38, 39–42, 490with vprintf(), 42

    print_r() function, 6, 93print_var() method, 284, 285, 288private directive, 75process control (pcntl) extension, 440product catalog, 205–211product ID, 172, 208, 213–219, 344, 345product page, 205–211product tables, 172, 177, 178products. See also widgets

    adding to shopping cart, 217, 218,333–334, 344

    browsing by category, 199–204calculating prices, 221deleting in shopping cart, 219, 223,

    335–336displaying in shopping cart, 219–223displaying online, 205–211invalid ID, 211names, 209out-of-stock, 210printing items in cart, 222retrieving information about, 217updating in shopping cart, 218–223, 333,

    335, 345, 346properties, 235, 281–288. See also specific

    propertiesprotected variable, 286

    PECL Filter, 136–142PECL json package, 507percent sign (%), 37, 42performance

    client/server, 80functions, 452–455OOP and, 234

    permissionscrontab file, 401directories, 378, 380–381files, 314, 315, 348, 381

    PHPaccessing Web sites with, 348–354distance calculation, 103errors. See error messages; errorsnetworking with, 347–372parsing XML with, 548, 550–555testing, 491, 524–527using COM with, 404–415versions, 81, 418

    PHP CLI help file, 418, 420, 421PHP CLI man page, 421PHP Coding Standard, 46php executable, 403, 430.php extension, 48, 424, 565PHP Extension and Application Repository.

    See PEARPHP Extension Code Library. See PECLPHP files, 199, 400–401PHP Library, 345PHP scripts. See scriptsPHP tags, 48, 555phpDocumentor, 46PHP-GTK, 385–398, 427PHP-GTK Web site, 385phpinfo() scripts, 125, 157, 374php.ini file, 406, 424phpMyAdmin, 10–11, 97, 174pipes, 415plus sign (+), 541polymorphism, 264–265POP port, 355popen() function, 415port value, 356ports, 355, 359

    585

    IndexIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 585

  • register_globals, 124registerRule() function, 465registration forms

    creating with Ajax, 484–505creating with HTML_QuickForm, 456–468default form values, 461filtering data, 461–465processing data, 466–468validating (Ajax), 484, 488–489, 499validating (QuickForm), 128–131, 138–139

    regular expressions, 124, 126, 131, 132Remote Procedure Calls (RPC), 530remote servers, 422renderers, 460Representational State Transfer (REST), 530required rule, 462require_once() function, 241, 243reset button, 456reset element type, 456responseText attribute, 513, 517responseText property, 495, 496, 525responseXML property, 495REST (Representational State Transfer), 530return_distance() function, 114, 507RETURNS clause, 111Rico software, 518Rijndael algorithm, 158root element, 532, 534–535, 562root folder, 54routines, stored, 110–115rows, 116–122, 395, 413RPC (Remote Procedure Calls), 530RSS (Really Simple Syndication), 562–568RSS feeds, 529, 562–568rtrim() function, 164Ruby technology, 518rules

    adding to form elements, 461–467email addresses, 462, 464, 465error messages, 464passwords, 465validation, 461–465

    run() method, 455

    proxy servers, 74proxy-revalidate directive, 75public directive, 75public variables, 285punctuation, 127PuTTY application, 422

    Qquery results

    displaying horizontally, 116–122reporting on, 15sent to browser, 8

    query value, 356question mark (?), 541QuickForms. See HTML_QuickForm

    package" entity, 536quotation marks (“), 284, 444, 445–455quote marks (‘), 444, 445–455

    R\r (carriage returns), 124r mode, 374r+ mode, 374radio button, 456radio element type, 456rangelength rule, 462Ray, Arpad, 518read access, 374“read” function, 84readgzfile() function, 375readyState property, 495, 496, 498, 499Really Simple Syndication. See RSSrecords. See also databases

    adding to database, 101, 178–181, 485–486backing up, 375–384displaying horizontally, 116–122retrieving, 379, 384, 413

    Rectangle class, 246–250Rectangle example, 244–250recursive functions, 18–24references, 30regex rule, 462

    586

    Inde

    xIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 586

  • semicolon (;), 111send() method, 523serialized arrays, 89server requests, 80, 482, 496servers, 373–415

    Ajax and, 482, 496Apache, 424cron utility, 399–401file compression, 374–384IIS (Internet Information Server), 424live vs. test, 53, 54, 187local, 53multiple, 82PHP and, 373PHP-GTK, 385–398proxy, 74remote, 422running commands on, 125, 415scheduling tasks (Mac OS X), 399, 400–401scheduling tasks (Unix), 399–401scheduling tasks (Windows), 402–403SMTP, 469using COM with PHP, 404–415

    server-side caching, 80server-side validation, 462, 466server-specific constants, 53–54, 187$_SESSION array, 88, 89session caching, 80session data, 82–95, 125session directory, 82, 125session functions, 84–90session handlers, 91–95session ID, 83, 88session table, 82session.auto_start function, 90session_cache_limit() function, 80session_destroy() function, 89sessions

    arguments, 84caching, 80closing, 94deleting, 89opening, 88security, 82storing in databases, 82–95

    SSafari browser, 527, 531SAJAX software, 518salutation element, 458SAX (Simple API for XML), 548SAX parsers, 548, 561scalar values, 111scanf() function, 42Scheduled Tasks (Windows), 402–403schema, 540, 546scheme value, 356scientific notation, 37scope resolution (::) operator, 289–293script.aculo.us, 518scripts. See also code

    Ajax examples, 487–490, 507–512benchmarking, 444–450CLI. See CLI scriptscomments, 44–46phpinfo(), 125, 157, 374running (Mac OS X), 424–425, 431running (Unix systems), 424–425, 431running (Windows), 403, 424–425,

    429–430testing, 491, 524–527time limits for, 362, 406–407

    search module, 70–73security, 123–167. See also authentication;

    passwordsbasics, 124–125captcha test, 135database connections, 422encryption, 149, 154, 157–167frameworks and, 72mail abuses, 124MCrypt, 157–167modularization and, 64, 65PEAR Auth package, 143–156session storage and, 82setAdvancedSecurity() method, 156validating forms, 126–135

    select element type, 456select menu, 456self keyword, 289

    587

    IndexIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 587

  • signals, 440signature, 280signed integer, 38Simple API for XML (SAX), 548, 561simple authentication, 144–150SimpleXML, 556–561sizes table, 172, 177, 179SKU numbers, 172, 178, 182slash (/), 189sleep() function, 269Smarty system, 58s-maxage directive, 75SMTP port, 355SMTP server, 469SOAP, 530sockets, 355–362sorting, 2–7, 26, 28specific_widgets table, 173, 178–181, 196SPL (Standard PHP Library), 345sprintf() function, 38, 39–42, 490SQL injection attacks, 125SQLite database, 83srand() function, 158SSH application, 422SSH port, 355SSL port, 355Standard Generalized Markup Language

    (SGML), 529standard input (STDIN) constant,

    437–439, 442standard integer, 37Standard PHP Library (SPL), 345start() method, 154static class attributes, 294–299static element type, 456static keyword, 294static members, 294–299static methods, 295–299static statement, 25–29static variables, 25–29, 294status property, 495, 496, 499stdClass class, 239STDIN (standard input) constant, 437–439, 442stored functions, 110–115stored routines, 110–115

    sessions table, 83session_save_path() function, 82session_set_save_handler() function, 84,

    90, 91session_start() function, 90, 93session_write_close() function, 91, 94, 95set_ method, 250setAdvancedSecurity() method, 156setAuthData() method, 156set_default_size() method, 394set_display() function, 391–392, 396setlocale() function, 127setMarker() function, 445–449set_number() function, 392–393, 396set_operator() function, 396set_size() method, 245, 247, 248, 255set_time_limit() function, 362, 406–407set_title() method, 394SGML (Standard Generalized Markup

    Language), 529SHA() function, 174, 485shebang line, 424–425shell scripting, 417shell_exec() function, 368, 415shopping cart

    adding items to, 217, 218, 333–334, 344calculating item prices, 221deleting items in, 219, 223, 335–336displaying contents, 219–223,

    337–339, 346HTML form for, 337–339links to, 210printing items in, 222retrieving product information, 217templates, 190, 191–196updating items in, 218–223, 333, 335,

    345, 346shopping cart application, 212–223shopping cart class, 328–339shopping cart page, 213–223show() method, 397show_all() method, 397show_login_form() function, 154show_stores() function, 517–519sign specifier (+/-), 37

    588

    Inde

    xIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 588

  • specific_widgets, 173, 178–181, 196stores, 100–102testing, 11zip code, 96–99

    task attribute, 9task_id attribute, 9, 10tasks

    adding to arrays, 23adding to database, 12–18nested to-do lists, 8–17recursion and, 18–24scheduling (Mac OS X), 399–401scheduling (Unix), 399–401scheduling (Windows), 402–403

    Telnet port, 355templates

    applications, 190–196e-commerce example, 190–196HTML, 58–61shopping cart, 190, 191–196Web pages, 58–61

    temporary directory, 82Terminal application, 400, 421testing

    Ajax applications, 504–505captcha test, 135CLI installation (Mac/Unix), 421CLI installation (Windows), 419–420code snippets, 422–423methods, 455PHP scripts, 491, 524–527scripts, 491, 524–527tables, 11validate() test, 466

    text blocks, 456text boxes, 456text element type, 456text input, 456textarea element type, 456textarea field, 456$this attribute, 244–250$this variable, 245–246throw syntax, 311time

    current, 378

    stores table, 100–102strcasecmp() function, 6, 352strcmp() function, 3strings

    formatting, 38heredoc syntax, 31–36specifiers, 37user input, 438XML, 561

    strip_tags() function, 125strtolower() function, 553subclass constructors, 272–275subclasses, 265, 276, 288, 298submit button, 456, 457, 460, 516, 520submit element type, 456superclass, 265switch case, 64switch conditional, 64–65, 238, 324synchronous transactions, 483system() function, 415

    Ttables

    addresses, 182backing up, 375–384categories, 172, 176–178, 193, 194colors, 172, 176, 179columns, 83, 98–100, 102, 413compression, 374–384creating with CREATE TABLE, 10, 151–152,

    174–178creating with GTK, 394–395creating with HTML, 116, 457customers, 171, 174, 182general_widgets, 173, 177–180joining, 102metadata, 171, 175order, 171, 172, 175order_contents, 172, 173, 175populating, 173, 178–180, 486product, 172, 177, 178retrieving, 379, 411sessions, 83sizes, 172, 177, 179

    589

    IndexIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 589

  • redirects, 348running applications through, 524unable to open, 352validating, 355–362

    user events, 386, 397user input, 438–442user value, 356usernames

    checking availability of, 485–505registered, 491

    usersadding, 145, 149events, 386, 397finding location of, 363–367input, 438–442MySQL, 145

    usort() function, 3, 6UTF-8 characters, 499

    Vvalidate() test, 466validation

    categories, 202client-side, 462, 464, 465–466conditionals, 202–204credit card, 224–232email addresses, 131, 462errors, 133form data (Ajax), 461–465form data (QuickForm), 128–131, 138–139passwords, 131, 465product ID, 208rules, 461–465server-side, 462, 466URL, 355–362usernames, 485–505

    var keyword, 493variable scope, 498variables

    checking values of, 525checking with JavaScript alerts, 525commands and, 125commenting, 45$debug, 54declaring, 110

    elapsed, 445, 449script time limits, 362, 406–407

    time zones, 228timeElapsed() method, 445, 449Timer class, 445–450timers, 445–450timestamp, 76, 78, 83, 175, 423TINYINT keyword, 102to-do list, 8–17toString() method, 311, 318transactions

    Ajax, 482, 483, 494synchronous vs. asynchronous, 483

    tree-based parsers, 548, 559Triangle class, 302–307trigger_error() function, 189trim() function, 462try block, 311, 314, 318try statement, 310try...catch blocks, 310, 311, 315, 318, 410type hinting, 319type specifiers, 37

    Uuasort() function, 3, 6uksort() function, 3Uniform Resource Indicators (URIs), 540Uniform Resource Locators. See URLsUnix servers, 399–401Unix-based systems

    binary files and, 382cron utility, 399–401remote server connections, 422running scripts, 424–425, 431Terminal application, 400, 421testing CLI installation on, 421

    UNIX_TIMESTAMP() function, 78unserialize() function, 343unsigned decimal integer, 37update_item() method, 333, 335, 345uploadedfile rule, 462URIs (Uniform Resource Indicators), 540URL links, 456URLs (Uniform Resource Locators)

    information passed via, 135

    590

    Inde

    xIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 590

  • Safari, 531Wget, 399XML and, 531

    Web pagesAjax applications, 482–528caching in, 74–80home page, 69, 197–198HTML templates, 58–61login functionality, 144–156logout functionality, 93–95opening, 355, 369–372ports, 355posting data to, 369–372product page, 205–211shopping cart page, 213–223titles, 60updates to, 482–483

    Web port, 355Web Services Description Language

    (WSDL), 530Web sites. See also specific Web sites

    accessing with PHP, 348–354authentication system, 143–156companion site to book, 170distance calculations on, 96–109e-commerce home page, 197–198home page, 69, 197–198HTML templates, 58–61modularizing, 49–73reading data from, 348–354sessions, 82structure, 48

    Wget browser, 399WHERE clause, 106while loop, 121, 413, 511white space, 44, 48, 533white space characters, 127widget ID, 343widgets, 385–386. See also productsWidgetShoppingCart class, 329–339, 340–346$window variable, 394Windows Vista systems, 420Windows XP systems, 410, 419–420Windows-based systems

    binary files and, 382

    filtering, 136–142flag, 202global, 25, 55, 137, 391–394included files and, 125initializing, 124local, 110names, 45, 110, 196$operator, 392–393passing by reference, 30protected, 286public, 285static, 25–29, 294$this, 245–246vs. attributes, 236$window, 394

    Venkman debugger, 527visibility, 234, 236, 265, 281–288Visual Basic editor, 404, 405vprintf() function, 42

    Ww mode, 374w+ mode, 374W3C (World Wide Web Consortium), 530Web applications, 43–80. See also applications

    caching and, 74–80code style/structure, 47–48configuration files, 50–57content modules, 66–69documenting code, 44–46HTML templates, 58–61index page, 62–65main module, 66–69main page, 62–65modularization and, 49–73search modules, 70–73

    Web browsersAjax applications, 482–528caching Web pages, 74–80Firefox, 493, 526, 527, 531, 565history feature, 528Internet Explorer, 74, 492, 526, 527, 531Lynx, 399query results sent to, 8RSS feeds, 562–568

    591

    IndexIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 591

  • browser-viewable, 531comments in, 533creating, 531, 534–535examples, 532–535nested elements in, 534structure of, 532valid, 544well-formed, 544white space and, 533

    XML elements, 530, 536–539XML prolog, 532XML Schema, 546XML strings, 561XML tags, 48, 530–534, 555XMLHttpRequest object, 492–496, 513xml_parse() function, 549xml_parse_create() function, 549, 554xml_parse_free() function, 549xml_set_character_data_handler()

    function, 549xml_set_element_hander() function, 549XPath language, 561XSLT (Extensible Stylesheet Language

    Transformation), 555

    YYahoo!, 530y-coordinates, 396year menu, 456Yeung, Anthony, 58

    ZZCTA (Zip Code Tabulation Areas), 96Zend, 72, 80Zend Framework, 354Zend Optimizer, 80zip code search example, 506–522zip code table, 96–99Zip Code Tabulation Areas (ZCTA), 96zip codes, 96–109zips database, 96–109, 507–521zlib library, 374–376zlib tool, 80, 374–376, 382

    Component Object Module (COM), 404–415MySQL Administrator, 112–113, 114remote server connections, 422running scripts, 403, 424–425, 429–430Scheduled Tasks, 402–403testing CLI installation on, 419–420

    Word documents, 404workbooks, Excel, 405, 406–415World Wide Web Consortium (W3C), 530write access, 374“write” function, 84write_session() function, 94WriteToFile class, 326WSDL (Web Services Description

    Language), 530

    Xx mode, 374XAJAX software, 518x-coordinates, 395, 396XHTML, 483, 529, 550XML (Extensible Markup Language),

    529–568Ajax and, 481, 483attributes, 536–539browsers and, 531Document Type Definitions, 540–547empty elements, 536–539entities, 536–539naming conventions, 533overview, 529, 530–531parsing with Expat, 548, 549–551, 555parsing with PHP, 548, 550–555parsing with SimpleXML, 556–561purpose of, 530RSS feeds, 562–568syntax, 532–535versions, 532vs. HTML, 125white space and, 533XPath language, 561

    XML data, 531, 544, 555, 556XML documents

    associating DTDs with, 540–547

    592

    Inde

    xIndex

    15_PHP5VQP(569-592).qxd 02/14/2007 11:59 AM Page 592