Hudzilla.org - the homepage of Paul Hudson PHP and PHP
Contents > Wish List | Report Bug | About Me ]

     Table of Contents

NOTE: This is NOT the latest copy of this book; click here for the latest version.

There are only four ground rules in place for reading this book:

  1. Please read the copyright notice and abide by it. Some day I hope to publish this thing, and that would be impossible if it were copied uncontrollably.
  2. Please do not use site downloaders to copy the book locally; it would hammer my web server, and is very selfish.
  3. Please consider buying me something from my Amazon.com wish list if this book helps you.





1. Preface
1.1. Is this book for you?
1.2. Who this book is not for
1.3. What you will get out of this book
1.4. How to use this book
1.5. A note for programmers coming from Perl
1.6. A note for programmers coming from C, C++, or Java
1.7. Cross-platform PHP
1.8. Tips for success
1.9. About the Publisher
1.10. Copyright and usage rights
1.11. Give something back!
1.12. About me
1.13. Acknowledgements
2. Introducing PHP
2.1. History
2.1.1. Background
2.1.2. Early versions of PHP
2.1.3. Current release
2.1.4. Upgrading from PHP 3
2.1.5. Upgrading from PHP 4
2.1.6. The creators of PHP
2.1.7. The Zend Relationship
2.2. Advantages of PHP
2.2.1. The HTML relationship
2.2.2. Interpreting vs. Compiling
2.2.3. Output Control
2.2.4. Performance
2.2.5. Competing Languages
2.2.6. When to use PHP
2.2.7. When not to use PHP
2.2.8. Selling PHP to your boss
2.3. Extending PHP
2.4. PEAR
2.5. Running PHP scripts
2.6. How PHP is written
2.6.1. Whitespace
2.6.2. Escape sequences
2.6.3. Heredoc
2.6.4. Brief introduction to variable types
2.6.5. Code blocks
2.6.6. Opening and closing code islands
2.6.7. Comments
2.6.8. Conditional statements
2.6.9. Case switching
2.6.10. Loops
2.6.11. Infinite loops
2.6.12. Special loop keywords
2.6.13. Loops within loops
2.6.14. Mixed-mode processing
2.6.15. Including other files
2.7. Abnormal script termination
2.8. Editing your PHP configuration
2.9. Summary
2.10. Exercises
2.11. Further reading
2.12. Next chapter
3. Simple variables and operators
3.1. Types of Data
3.2. Checking a variable is set: isset()
3.3. Automatic type conversion
3.4. Forcing a type with type casting
3.5. Non-decimal number systems
3.6. Variable scope
3.7. Variable variables
3.8. Superglobals
3.9. Pre-set variables
3.10. References
3.11. Constants: define(), defined(), and constant()
3.11.1. Pre-set constants
3.12. Operators
3.12.1. Shorthand unary operators
3.12.2. Comparison operators
3.12.3. Complete operator list
3.12.4. The Ternary Operator
3.12.5. The scope resolution operator
3.12.6. The execution operator
3.12.7. Operator precedence and associativity
3.13. Summary
3.14. Exercises
3.15. Further reading
3.16. Next chapter
4. Functions
4.1. Functions overview
4.2. How to read function prototypes
4.3. Working with variables: isset(), empty(), and unset()
4.4. Controlling script execution: exit(), eval(), and die()
4.5. Working with Date and Time
4.5.1. Reading the current time: time() and microtime()
4.5.2. Converting from a string: strtotime()
4.5.3. Converting to a string: date()
4.5.4. Converting from components: mktime()
4.6. Mathematics
4.6.1. Rounding: ceil(), floor(), and round()
4.6.2. Randomisation: rand(), mt_rand(), getrandmax(), mt_getrandmax(), srand(), and mt_srand()
4.6.3. Trigonometrical conversion: sin(), cos(), tan(), asin(), acos(), and atan(), deg2rad(), rad2deg()
4.6.4. Other mathematical conversion functions: abs(), sqrt(), pow, and hypot()
4.6.5. Base conversion: bindec(), decbin(), dechex(), decoct(), hexdec(), octdec(), and base_convert()
4.6.6. Mathematical constants
4.7. Playing with strings
4.7.1. Reading from part of a string: substr()
4.7.2. Replacing parts of a string: str_replace() and str_ireplace()
4.7.3. Converting to and from ASCII: chr() and ord()
4.7.4. Measuring strings: strlen(), count_chars(), and str_word_count()
4.7.5. Finding a string within a string: strpos() and stripos()
4.7.6. Returning the first occurrence of a string: strstr() and stristr()
4.7.7. Trimming whitespace: trim(), ltrim(), and rtrim()
4.7.8. Wrapping your lines: wordwrap()
4.7.9. Changing string case: strtoupper(), strtolower(), ucfirst(), and ucwords()
4.7.10. Making a secure data hash: sha1()
4.7.11. Alternative data hashing: md5()
4.7.12. Automatically escaping strings: addslashes() and stripslashes()
4.7.13. Pretty-printing numbers: number_format()
4.7.14. Removing HTML from a string: strip_tags()
4.7.15. Comparing strings: strcmp() and strcasecmp()
4.7.16. Padding out a string: str_pad()
4.7.17. Complex string printing: printf()
4.7.18. Parsing a string into variables: parse_str()
4.8. Regular expressions
4.8.1. Basic regexps with preg_match() and preg_match_all()
4.8.2. Novice regexps
4.8.3. Advanced regexps
4.8.4. Guru regexps
4.8.5. Regular expression replacements: preg_replace()
4.8.6. Regular expression syntax examples
4.8.7. The regular expressions coach
4.9. Checking whether a function is available: function_exists()
4.10. Extension functions: get_loaded_extensions(), get_extension_funcs(), dl(), and extension_loaded()
4.11. Pausing script execution: sleep() and usleep()
4.12. Executing external programs: exec(), passthru(), and virtual()
4.13. Connection-related functions: ignore_user_abort(), register_shutdown_function(), and connection_status()
4.14. Altering the execution environment: ini_get(), ini_set(), and set_time_limit()
4.15. User functions
4.15.1. Return values
4.15.2. Parameters
4.15.3. Passing by reference
4.15.4. Returning by reference
4.15.5. Default parameters
4.15.6. Variable parameter counts: func_num_args(), func_get_arg(), and func_get_args()
4.16. Variable scope in functions
4.17. Overriding scope with the GLOBALS array
4.18. Recursive functions
4.19. Variable functions: is_callable(), call_user_func() and call_user_func_array()
4.20. Callback functions
4.21. The declare() function and ticks: declare(), register_tick_function(), and unregister_tick_function()
4.22. Handling non-English characters
4.23. Undocumented functions
4.24. Summary
4.25. Exercises
4.26. Further reading
4.27. Next chapter
5. Arrays
5.1. First steps: array(), count(), print_r(), var_dump(), and var_export()
5.2. Associative arrays
5.3. The three ways of iterating through arrays: list(), each(), and foreach loops
5.4. The array operator
5.5. Returning arrays from functions
5.6. Array-specific functions
5.6.1. Chopping and changing arrays: array_diff(), array_intersect(), and array_merge()
5.6.2. Stripping out duplicate values: array_unique()
5.6.3. Filtering your array through a function: array_filter()
5.6.4. Converting an array to individual variables: extract()
5.6.5. Checking whether an element exists: in_array()
5.6.6. Using an array as a double-ended queue: array_shift(), array_unshift(), array_push(), array_pop()
5.6.7. Swapping keys and values: array_flip()
5.6.8. Sorting arrays: asort(), ksort(), arsort(), and krsort()
5.6.9. Grabbing keys and values: array_keys() and array_values()
5.6.10. Randomising your array: shuffle() and array_rand()
5.6.11. Creating an array of numbers: range()
5.7. Multidimensional arrays
5.8. The array cursor: reset(), end(), next(), and prev()
5.9. Holes in arrays
5.10. Arrays in strings
5.11. Saving arrays: serialize(), unserialize(), urlencode(), and urldecode()
5.12. Summary
5.13. Exercises
5.14. Further reading
5.15. Next chapter
6. Objects
6.1. Conceptual overview
6.2. Classes
6.2.1. Defining a class
6.2.2. How to design your class
6.2.3. Basic inheritance
6.2.4. Overriding functions
6.3. Objects
6.4. Variables
6.5. The 'this' variable
6.6. Objects within objects
6.7. Access control modifiers
6.7.1. Public
6.7.2. Private
6.7.3. Protected
6.7.4. Final
6.7.5. Abstract
6.7.6. Iterating through object variables
6.8. Object type information: instanceof and is_subclass_of()
6.9. Class type hints
6.10. Constructors and destructors
6.10.1. Parent constructors
6.10.2. Destructors
6.10.3. Deleting objects
6.11. Copying objects
6.12. Comparing objects with == and ===
6.13. Saving objects: __sleep(), __wakeup(), and get_object_vars()
6.14. Magic functions
6.14.1. __autoload()
6.14.2. __get()
6.14.3. __set()
6.14.4. __call()
6.14.5. __toString()
6.15. Static data
6.16. Helpful utility functions: class_exists(), get_class(), and get_declared_classes()
6.17. Interfaces: get_declared_interfaces()
6.18. Deferencing object return values
6.19. The Object-Oriented Website
6.19.1. A basic OOP site
6.19.2. A more complex OOP website
6.20. Summary
6.21. Exercises
6.22. Further reading
6.23. Next chapter
7. HTML Forms
7.1. The state of play
7.2. What does it mean to be dynamic?
7.3. Designing a form
7.3.1. GET and POST
7.3.2. Available elements
7.3.3. A working form
7.4. Handling data
7.4.1. register_globals
7.4.2. Working around register_globals: import_request_variables()
7.4.3. Magic quotes
7.4.4. Data handling summary
7.4.5. Handling our form
7.5. Splitting forms across pages
7.6. Files sent through forms
7.7. Validating input
7.7.1. Client-side validation
7.7.2. Server-side validation
7.7.3. Validation in practice: is_string(), is_numeric(), is_float(), is_array(),is_object(), and is_resource()
7.7.4. Advanced variable validation using CTYPE
7.7.5. Key validation points
7.8. Form design
7.9. Summary
7.10. Exercises
7.11. Further reading
7.12. Next chapter
8. Files
8.1. Reading files
8.1.1. readfile()
8.1.2. file_get_contents() and file()
8.1.3. fopen() and fread()
8.2. Creating and changing files
8.2.1. file_put_contents()
8.2.2. fwrite()
8.3. Moving, copying, and deleting files: rename(), copy(), and unlink()
8.3.1. Moving files with rename()
8.3.2. Copying files with copy()
8.3.3. Deleting files with unlink()
8.4. Temporary files: tmpfile()
8.5. Other file functions: rewind(), and fseek()
8.6. Checking whether a file exists: file_exists()
8.7. Retrieving a file's status: is_readable(), is_writeable(), is_executable(), is_file(), is_dir(), and clearstatcache()
8.8. Dissecting filename information: pathinfo() and basename()
8.9. A working example: making a counter
8.10. Handling file uploads: move_uploaded_file()
8.10.1. Advanced file upload handling
8.10.2. Checking uploaded files: is_uploaded_file()
8.11. Locking files with flock()
8.12. Permissions
8.12.1. Setting permissions: chmod()
8.12.2. Changing file ownership: chown()
8.13. Working with directories: opendir(), readdir(), and closedir()
8.13.1. Deleting directories: rmdir()
8.13.2. One last directory function: scandir()
8.14. Remote files
8.15. File checksums: sha1_file() and md5_file()
8.16. Parsing a configuration file: parse_ini_file()
8.17. Summary
8.18. Exercises
8.19. Further reading
8.20. Next chapter
9. Databases
9.1. Introduction
9.1.1. Database hierarchy
9.1.2. Types of data
9.1.3. Date and time
9.1.4. Transactions
9.1.5. Stored procedures
9.1.6. Triggers
9.1.7. Views
9.1.8. Keys
9.1.9. Referential integrity
9.1.10. Indexes
9.1.11. Persistent connections
9.1.12. Temporary Tables
9.1.13. Table handlers
9.1.14. Round up
9.2. History
9.2.1. MySQL
9.2.2. PostgreSQL
9.2.3. Oracle
9.2.4. Microsoft SQL Server
9.3. SQL
9.3.1. SQL comments
9.3.2. Interacting with MySQL
9.3.3. Creating tables
9.3.4. Making table changes
9.3.5. Deleting tables
9.3.6. Inserting data
9.3.7. Selecting data
9.3.8. Extra SELECT keywords
9.3.9. Updating data
9.3.10. Deleting data
9.3.11. MySQL for dummies
9.3.12. A working example
9.3.13. Multiple WHERE conditions
9.3.14. Grouping rows together with GROUP BY
9.3.15. MySQL functions
9.3.16. Managing indexes
9.3.17. Simple text searching using LIKE
9.3.18. Advanced text searching using full-text indexes
9.3.19. Range matching: between() and in()
9.3.20. NULL
9.3.21. Default values
9.4. Using MySQL with PHP
9.4.1. Connecting to a MySQL database: mysql_connect(), mysql_select_db()
9.4.2. Querying and formatting: mysql_query() and mysql_num_rows()
9.4.3. Disconnecting from a MySQL database: mysql_free_result() and mysql_close()
9.4.4. Reading in data: mysql_fetch_assoc()
9.4.5. Mixing in PHP variables: mysql_escape_string()
9.4.6. Results within results
9.4.7. Advanced formatting
9.4.8. Reading auto-incrementing values: mysql_insert_id()
9.4.9. Unbuffered queries for large data sets: mysql_unbuffered_query()
9.5. phpMyAdmin
9.6. PEAR::DB
9.6.1. Quick PEAR::DB calls
9.6.2. Query information
9.6.3. Advanced PEAR::DB
9.6.4. Impeared performance?
9.7. SQLite
9.7.1. Using SQLite
9.7.2. Before you begin
9.7.3. Getting started: sqlite_open(), sqlite_close(), sqlite_query(), and sqlite_fetch_array()
9.7.4. Advanced functions: sqlite_last_insert_rowid(), sqlite_fetch_single(), and sqlite_array_query()
9.7.5. Mixing SQLite and PHP: sqlite_create_function()
9.8. Normalisation
9.8.1. Why separate data?
9.8.2. So, what is the solution here?
9.8.3. Why not separate data?
9.8.4. First normal form
9.8.5. Second normal form
9.8.6. Other normal forms
9.8.7. Conclusion
9.9. Table joins
9.9.1. Complex joins
9.10. Using temporary tables
9.11. Adjusting the priority queue
9.12. How to design your tables
9.13. Picking the perfect data type
9.14. When MySQL knows best
9.15. Persistent connections: mysql_pconnect() and sqlite_popen()
9.16. Choosing a table type
9.17. Transactions
9.18. MySQL Improved
9.19. Subselects, views, and other advanced functions
9.19.1. Subselects
9.19.2. Views
9.19.3. Referential integrity
9.20. Summary
9.21. Exercises
9.22. Further reading
9.23. Next chapter
10. Cookies and Sessions
10.1. Cookies vs. Sessions
10.1.1. Cookies
10.1.2. Sessions
10.1.3. Choosing the appropriate option
10.2. Using cookies: setcookie()
10.3. Using sessions
10.3.1. Starting a session: session_start()
10.3.2. Adding session data
10.3.3. Reading session data
10.3.4. Removing session data
10.3.5. Ending a session: session_destroy()
10.3.6. Checking session data
10.3.7. Files vs. Databases: session_set_save_handler()
10.4. Storing complex data types
10.5. Summary
10.6. Exercises
10.7. Further reading
10.8. Next chapter
11. Multimedia
11.1. Brief history of web media
11.1.1. GIF
11.1.2. PNG
11.1.3. JPEG
11.1.4. RTF
11.1.5. PDF
11.1.6. Flash
11.1.7. SVG
11.2. Images
11.2.1. Creating new images: imagecreate(), imagedestroy(), imagecolorallocate()
11.2.2. Choosing a format
11.2.3. Getting arty: imagefilledrectangle()
11.2.4. More shapes: imagecreatetruecolor(), imagefilledellipse(), imagefilledarc(), imageellipse(), imagearc(), and imagerectangle()
11.2.5. Complex shapes: imagefilledpolygon() and imagepolygon()
11.2.6. Outputting text: imagettftext() and imagettfbbox()
11.2.7. Loading existing images: imagecreatefrompng(), imagecreatefromjpeg(), and getimagesize()
11.2.8. Colour and image fills: imagefill(), imagefilltoborder(), and imagesettile()
11.2.9. Adding transparency: imagecolortransparent()
11.2.10. Using brushes: imagesetbrush()
11.2.11. Basic image copying: imagecopy() and imagecopymerge()
11.2.12. Scaling and rotating: imagecopyresized(), imagecopyresampled(), and imagerotate()
11.2.13. Points and lines: imagesetpixel(), imageline(), and imagesetthickness()
11.2.14. Updating the drawing script
11.2.15. Special effects using imagefilter()
11.2.16. Introduction to special effects using simple algorithms
11.2.17. Special FX, Colour reduction: imagetruecolortopalette()
11.2.18. Special FX, Interlacing
11.2.19. Special FX, Screen
11.2.20. Special FX, Greyscale: imagecolorat()
11.2.21. Special FX, Duotone
11.2.22. Special FX, Noise
11.2.23. Special FX, Scatter
11.2.24. Special FX, Pixelate
11.2.25. Special FX, Blur
11.2.26. Special FX, Other special effects
11.2.27. Interlacing an image: imageinterlace()
11.2.28. Getting an image's MIME type: image_type_to_mime_type()
11.2.29. Keeping your files small
11.2.30. Making graphs
11.3. Working with RTF
11.4. Creating PDF documents
11.4.1. There's more than one way to do it
11.4.2. Getting started: pdf_new(), pdf_open_file(), pdf_findfont(), pdf_begin_page(), pdf_setfont(), pdf_show_xy(), pdf_end_page(), pdf_close(), and pdf_delete()
11.4.3. Adding more pages and more style: pdf_setcolor()
11.4.4. Adding imagery: pdf_open_image_file() and pdf_place_image()
11.4.5. PDF special effects: pdf_rotate() and pdf_skew()
11.4.6. Adding document data: pdf_add_note(), pdf_set_info()
11.4.7. PDF Conclusion
11.4.8. Point sizes in real life
11.4.9. ClipPDF interoperability
11.4.10. PDF without a module?
11.5. Creating Flash
11.5.1. A simple movie
11.5.2. Flashy text
11.5.3. Actions
11.5.4. Animation
11.5.5. Flash Conclusion
11.6. Summary
11.7. Exercises
11.8. Further reading
11.9. Next chapter
12. XML & XSLT
12.1. Introduction to XML
12.2. Event-based parsing
12.2.1. Creating a parser: xml_parser_create() and xml_parser_free()
12.2.2. Getting to know callback functions
12.2.3. Callback function implementation
12.2.4. Event-based XML parsing, at last!
12.2.5. Bringing Everything Together
12.3. SimpleXML
12.3.1. First steps
12.3.2. Reading from a string
12.3.3. Searching and filtering with XPath
12.3.4. Outputting XML: asXML()
12.4. Transforming XML using XSLT
12.4.1. Adding PHP to the mix
12.4.2. Handling the processed output
12.4.3. Making XSL work for its money
12.4.4. What else can XSL do?
12.4.5. XSLT Conclusion
12.5. Summary
12.6. Exercises
12.7. Further reading
12.8. Next chapter
13. Output Buffering
13.1. Advantages
13.2. Performance Considerations
13.3. Getting started: ob_start(), ob_end_flush(), and ob_end_clean()
13.4. Reusing buffers: ob_flush() and ob_clean()
13.5. Stacking buffers
13.6. Flushing stacked buffers
13.7. Reading buffers: ob_get_contents()
13.8. Other OB functions: ob_get_length(), ob_get_level(), and ob_list_handlers()
13.9. Flushing output: flush()
13.10. Compressing output
13.11. URL rewriting: output_add_rewrite_var() and output_reset_rewrite_vars()
13.12. Summary
13.13. Exercises
13.14. Further reading
13.15. Next chapter
14. Java and COM
14.1. Getting started with COM
14.1.1. Instantiating an object
14.1.2. Basic COM
14.1.3. Advanced COM
14.1.4. The possibilities of COM
14.1.5. DCOM
14.1.6. Microsoft .NET
14.2. Bringing Java into the mix
14.2.1. Basic Java use
14.2.2. The drawbacks of basic Java use
14.2.3. Your own classes
14.2.4. Using Swing
14.2.5. The future of PHP and Java
14.3. Summary
14.4. Exercises
14.5. Further reading
14.6. Next chapter
15. Networks
15.1. Sockets
15.1.1. Sockets are files: fsockopen()
15.1.2. Making a simple search engine
15.1.3. Sockets aren't all about HTTP
15.1.4. Sockets can be servers: socket_create_listen(), socket_accept(), socket_write(), socket_read(), and socket_close()
15.1.5. Sockets can be powerful
15.2. Domain resolution functions: dns_check_record(), dns_get_mx(), and dns_get_record()
15.3. Host and IP resolution: gethostbyaddr(), gethostbyname(), and gethostbynamel()
15.4. HTTP
15.4.1. Sending custom headers: header() and headers_sent()
15.4.2. Reading queued headers: headers_list()
15.4.3. Authentication over HTTP
15.4.4. Dynamic authentication
15.5. Sending mail: mail()
15.5.1. MIME types: mime_content_type()
15.5.2. Easier mail sending with PEAR::Mail
15.5.3. Sending mixed-type messages with PEAR::Mail_Mime
15.5.4. Sending attachments (at last!)
15.6. Reading mail
15.6.1. Opening a mailbox: imap_open() and imap_close()
15.6.2. Reading message information: imap_headers() and imap_header()
15.6.3. Reading message contents: imap_num_msg() and imap_body()
15.7. Dealing with MIME-encoded messages: imap_fetchbody()
15.8. Mail management: imap_sort(), imap_delete(), imap_undelete(), imap_expunge(), imap_mailboxmsginfo(), and imap_last_error()
15.9. Transferring files over FTP: ftp_connect(), ftp_login(), ftp_pasv(), ftp_chdir(), ftp_get(), and ftp_close()
15.9.1. Other helpful FTP functions: ftp_put(), ftp_systype(), ftp_rename(), ftp_mkdir(), and ftp_rmdir()
15.10. Curl
15.10.1. Installing Curl
15.10.2. Your first Curl scripts: curl_init(), curl_setopt(), curl_exec(), curl_close()
15.10.3. The abridged list of Curl options
15.10.4. Debugging Curl
15.11. Custom data stream handling
15.11.1. The Morse code stream: stream_wrapper_register()
15.12. Summary
15.13. Exercises
15.14. Further reading
15.15. Next chapter
16. Miscellaneous topics
16.1. Process control
16.1.1. Taking control of PHP: pcntl_signal()
16.1.2. Timing your signals: pcntl_alarm()
16.1.3. Getting into multiprocessing: pcntl_fork(), pcntl_waitpid(), and pcntl_wexitstatus()
16.1.4. Duplication of resources when forking
16.1.5. The third parameter to pcntl_waitpid()
16.1.6. Event-driven child termination
16.1.7. Other ways to evaluate pcntl_waitpid()'s return value: pcntl_wifexited(), pcntl_wifsignaled(), pcntl_wifstopped(), pcntl_wtermsig(), and pcntl_wstopsig()
16.1.8. Running programs in the current process space: pcntl_exec()
16.1.9. Piping between processes: proc_open() and proc_close()
16.2. POSIX functions
16.2.1. Error handling: posix_get_last_error() and posix_strerror()
16.3. The Standard PHP Library
16.4. Reflection
16.5. Browser detection
16.6. Arbitrary-precision mathematics
16.7. Spellchecking and text matching
16.7.1. Calculating similarity of words: similar_text()
16.8. Templates
16.8.1. Templates ABC
16.8.2. How do they work?
16.8.3. When not to use templates
16.8.4. Writing your own
16.9. Summary
16.10. Exercises
16.11. Further reading
16.12. Next chapter
17. Security concerns
17.1. Programming secure PHP
17.1.1. register_globals
17.1.2. Choose your file extension carefully
17.1.3. Put key files outside your document root
17.1.4. Remember that most files are public
17.1.5. Hide your identity
17.1.6. Hiding PHP
17.1.7. Restrict general database access
17.1.8. Restrict PHP database access
17.1.9. Denial of service
17.1.10. Pre-initialise important variables to safe values
17.1.11. Be wary of session fixation
17.2. Hosting PHP
17.2.1. Understanding the concerns
17.2.2. Safe mode
17.3. Protecting your data
17.3.1. Data encryption
17.3.2. Terms you need to know
17.3.3. Asymmetric vs. Symmetric
17.3.4. Basic symmetric encryption in action: str_rot13()
17.3.5. Advanced symmetric encryption
17.3.6. Symmetric decryption: mdecrypt_generic()
17.3.7. Changing encryption algorithm
17.3.8. Changing block cipher mode
17.4. Hardened PHP
17.5. Summary
17.6. Exercises
17.7. Further reading
17.8. Next chapter
18. Performance
18.1. Optimising your code
18.1.1. Write your code sensibly
18.1.2. Use your tools wisely
18.1.3. Avoid function for maximum performance
18.1.4. Use the Zend Optimizer
18.1.5. Use a PHP code cache
18.1.6. Read the manual carefully
18.1.7. Get your loops right first
18.1.8. Pre-increment where possible
18.1.9. Don't think that using references will lower your RAM usage
18.1.10. Be wary of garbage collection, part 1
18.1.11. Be wary of garbage collection, part 2
18.1.12. Listen to all errors, big and small
18.1.13. Keep up to date
18.1.14. Cache array data
18.1.15. Compress your output
18.1.16. Don't use CGI
18.1.17. Don't use dl()
18.1.18. Debug your code
18.1.19. Cache your pages
18.1.20. Use persistent connections
18.1.21. Take advantage of new features
18.1.22. Compile right
18.1.23. Ignore the myths
18.1.24. Avoid mod_access if you can
18.1.25. Don't fret about Apache 2.0
18.2. Optimising your SQL
18.2.1. Prioritise your data
18.2.2. Optimise your tables
18.2.3. Select as little data as possible
18.2.4. Use shorter queries where possible
18.2.5. Use the EXPLAIN statement
18.2.6. Change your hardware
18.2.7. Choose your data types carefully
18.2.8. Size vs. Speed
18.2.9. Declare fields NOT NULL
18.2.10. Load data intelligently
18.2.11. Consider splitting off variable-length fields
18.2.12. Be wary of locks
18.2.13. Consider switching OS
18.2.14. Spot slow queries
18.2.15. Perform joins carefully
18.2.16. Index your data
18.2.17. Make sure your indexes are being used
18.2.18. Normalisation
18.2.19. Upgrade MySQL
18.2.20. Increase your buffers
18.2.21. Keep tabs on your server
18.2.22. Lock your tables when appropriate
18.2.23. Don't rely on automatic type conversion
18.2.24. Benchmark, benchmark, benchmark!
18.2.25. Know MySQL's strengths
18.3. Server
18.4. PHP Accelerators
18.5. Caching PHP
18.6. PHP as a CGI or a module?
18.7. Size of scripts
18.8. Summary
18.9. Exercises
18.10. Further reading
18.11. Next chapter
19. Writing PHP
19.1. The design process
19.1.1. Analysing the requirements
19.1.2. Designing the solution
19.1.3. Developing the code
19.1.4. Implementing the application
19.1.5. Maintenance and support
19.2. Which IDEs are good
19.2.1. Line numbering
19.2.2. Syntax highlighting
19.2.3. Online help
19.2.4. Code insight
19.2.5. Interactive debugging
19.2.6. Profiling
19.2.7. Popular IDEs
19.3. Laying out your files
19.3.1. Directory structuring
19.4. Group development
19.4.1. How to develop code
19.4.2. Version control
19.5. Documenting your project
19.6. Testing: php_check_syntax()
19.7. Distributing your code
19.7.1. Charging for your work
19.7.2. PHP Encoders
19.7.3. Cross-platform code 1: Loading extensions
19.7.4. Cross-platform code 2: Using extensions
19.7.5. Cross-platform code 3: Path and line separators
19.7.6. Cross-platform code 4: Coping with php.ini differences
19.7.7. Cross-platform code 5: Checking the PHP version with phpversion() and version_compare()
19.8. Debugging
19.8.1. What is a bug?
19.8.2. The most basic debugging technique: debug_zval_dump()
19.8.3. Making assertions: assert() and assert_options()
19.8.4. Triggering your own errors: trigger_error()
19.8.5. Source highlighting: highlight_file() and highlight_string()
19.8.6. Handling MySQL errors: mysql_error()
19.8.7. Exception handling
19.8.8. Backtracing your code: debug_backtrace()
19.8.9. Debuggers
19.8.10. Custom error handlers: set_error_handler(), restore_error_handler(), and error_log()
19.8.11. Custom exception handlers: set_exception_handler() and restore_exception_handler()
19.8.12. Using @ to disable errors
19.8.13. phpinfo()
19.9. Debugging practice
19.10. Coding style
19.10.1. Comments and whitespace
19.10.2. Variable naming
19.10.3. Functions
19.10.4. Distinguishing code blocks
19.11. Output style
19.11.1. Options for Tidy
19.12. Troubleshooting
19.12.1. Error types
19.12.2. Choosing what types of errors you see: error_reporting()
19.12.3. Common errors
19.13. Getting Help
19.13.1. The documentation
19.13.2. Mailing lists
19.13.3. Websites
19.13.4. IRC
19.13.5. Conferences
19.13.6. User groups
19.13.7. Submitting a bug
19.13.8. Contacting the author
19.14. Getting qualified
19.15. Summary
19.16. Exercises
19.17. Further reading
19.18. Next chapter
20. Writing extensions
20.1. Why write your own extension?
20.1.1. The C Perspective
20.2. Before we begin
20.3. First steps
20.4. Hello world - in C!
20.5. C Hello World v2
20.6. Factorials in C
20.7. Extensions Conclusion
20.8. Summary
20.9. Further reading
20.10. Next chapter
21. Alternative PHP uses
21.1. What else can be done with PHP?
21.2. Command-line scripting
21.2.1. Why use shell scripts?
21.2.2. CLI SAPI differences
21.2.3. Your first CLI script
21.2.4. Advanced command-line parsing: getopt()
21.2.5. Getting down and dirty
21.2.6. Getting into the swing of things
21.2.7. Sending code direct to PHP
21.2.8. The grand finale
21.2.9. CLI Conclusion
21.3. Graphical user interfaces
21.3.1. Getting started
21.3.2. GUI toolkits
21.3.3. A Basic GUI
21.3.4. Multiple Windows
21.3.5. Handling popup menus
21.3.6. Advanced GUIs
21.3.7. Using Custom Parameters
21.3.8. GUI Themes
21.3.9. Distributing your apps
21.3.10. Graphical Interfaces Conclusion
21.4. Making games
21.4.1. Text-based world planning
21.4.2. Text game v1
21.4.3. Getting graphical
21.4.4. Getting it to work
21.4.5. First steps
21.4.6. Moving our sprite: phpSDL_GetKeyState()
21.4.7. Clearing the screen: phpSDL_MapRGB() and phpSDL_FillRect()
21.4.8. Last tweaks: phpSDL_WM_SetCaption(), phpSDL_SetColorKey(), and phpSDL_GetTicks()
21.4.9. Games conclusion
21.5. Making your own language
21.5.1. Why make your own language?
21.5.2. The elements of a compiler
21.5.3. Analysis
21.5.4. Output
21.5.5. Planning it out
21.5.6. How to parse text into tokens
21.5.7. What is a token?
21.5.8. How parsing works
21.5.9. Finally, execution
21.5.10. If you have made it this far...
21.5.11. Operator precedence
21.5.12. The script in (almost) full
21.5.13. Mini-language conclusion
21.6. Summary
21.7. Further reading
21.8. Next chapter
22. Practical PHP
22.1. Creating a poll
22.1.1. Analysis: what makes a web poll?
22.1.2. Development: creating the simplest poll
22.1.3. Analysis: Poll v2
22.1.4. Putting Poll v2 into action
22.1.5. Analysis: Poll 2005
22.1.6. Making the final poll
22.1.7. Building a better poll
22.2. Creating a guestbook
22.2.1. Analysis
22.2.2. Development
22.2.3. Problems in paradise: Guestbook v2
22.2.4. Fixing the problems
22.2.5. Building a better guestbook
22.3. Creating a messageboard
22.3.1. Analysis
22.3.2. Development
22.3.3. Analysis: Messageboard v1.1
22.3.4. Making Messageboard v1.1
22.3.5. Messageboard v2
22.3.6. Making an object-oriented messageboard
22.4. Creating thumbnails
22.4.1. Analysis
22.4.2. Development
22.5. ASCII art
22.5.1. Analysis
22.5.2. Development
22.5.3. Analysis: ASCII art in colour
22.6. Further Reading
23. Bringing it to a close
24. Answers to Exercises
24.1. Answers to Chapter 2
24.2. Answers to Chapter 3
24.3. Answers to Chapter 4
24.4. Answers to Chapter 5
24.5. Answers to Chapter 6
24.6. Answers to Chapter 7
24.7. Answers to Chapter 8
24.8. Answers to Chapter 9
24.9. Answers to Chapter 10
24.10. Answers to Chapter 11
24.11. Answers to Chapter 12
24.12. Answers to Chapter 13
24.13. Answers to Chapter 14
24.14. Answers to Chapter 15
24.15. Answers to Chapter 16
24.16. Answers to Chapter 17
24.17. Answers to Chapter 18
24.18. Answers to Chapter 19
25. The future of PHP
25.1. Helping out PHP development
25.2. Choosing an ISP
25.2.1. Does your ISP support PHP?
25.3. Optimisation summary
26. Glossary


<< Table of Contents   Table of Contents >>
Table of Contents
Top-right shadow
 
Bottom-left shadow Bottom shadow