Book description
Serving as a complete introduction to PHP 5.3, this book walks you through all the major concepts of PHP in a way that's easy to follow, with plenty of code snippets illustrating each concept to aid learning. You'll discover how to install and configure PHP 5.3, how to get started with simple programs, and the basic building blocks of PHP such as variables, operators, expressions, arrays, and objects. Coverage working with files, XML, and MySQL; building Web applications with PHP; exploring the PEAR library; handling e-mail; and creating Web graphics.
Table of contents
- Copyright
- About the Author
- Credits
- Acknowledgments
- Introduction
- I. Getting Up and Running with PHP
-
II. Learning the Language
- 3. PHP Language Basics
- 4. Decisions and Loops
-
5. Strings
- 5.1. Creating and Accessing Strings
- 5.2. Searching Strings
- 5.3. Replacing Text within Strings
- 5.4. Dealing with Upper- and Lowercase
-
5.5. Formatting Strings
- 5.5.1. General-Purpose Formatting with printf() and sprintf()
- 5.5.2. Using Type Specifiers
- 5.5.3. Specifying Signs
- 5.5.4. Padding the Output
- 5.5.5. Specifying Number Precision
- 5.5.6. Swapping Arguments
- 5.5.7. Storing the Result Instead of Printing It
- 5.5.8. Trimming Strings with trim(), ltrim(), and rtrim()
- 5.5.9. Padding Strings with str_pad()
- 5.5.10. Wrapping Lines of Text with wordwrap()
- 5.5.11. Formatting Numbers with number_format()
- 5.6. Summary
- 5.7. Exercises
-
6. Arrays
- 6.1. The Anatomy of an Array
- 6.2. Creating Arrays
- 6.3. Accessing Array Elements
- 6.4. Looping Through Arrays with foreach
- 6.5. Working with Multidimensional Arrays
-
6.6. Manipulating Arrays
- 6.6.1. Sorting Arrays
- 6.6.2. Sorting Indexed Arrays with sort() and rsort()
- 6.6.3. Sorting Associative Arrays with asort() and arsort()
- 6.6.4. Sorting Associative Array Keys with ksort() and krsort()
- 6.6.5. Multi-Sorting with array_multisort()
- 6.6.6. Adding and Removing Array Elements
- 6.6.7. Adding and Removing Elements at the Start and End
- 6.6.8. Adding and Removing Elements in the Middle
- 6.6.9. Merging Arrays Together
- 6.6.10. Converting Between Arrays and Strings
- 6.6.11. Converting an Array to a List of Variables
- 6.7. Summary
- 6.8. Exercises
- 7. Functions
-
8. Objects
- 8.1. What Is Object-Oriented Programming?
- 8.2. Advantages of OOP
- 8.3. Understanding Basic OOP Concepts
- 8.4. Creating Classes and Objects in PHP
- 8.5. Creating and Using Properties
- 8.6. Working with Methods
- 8.7. Object Overloading with ___get(), ___set(), and ___call()
- 8.8. Using Inheritance to Extend the Power of Objects
- 8.9. Constructors and Destructors
- 8.10. Automatically Loading Class Files
- 8.11. Storing Objects as Strings
- 8.12. Determining an Object's Class
- 8.13. Summary
- 8.14. Exercises
-
III. Using PHP in Practice
- 9. Handling HTML Forms with PHP
- 10. Preserving State With Query Strings, Cookies, and Sessions
-
11. Working with Files and Directories
- 11.1. Understanding Files and Directories
- 11.2. Getting Information on Files
- 11.3. Opening and Closing Files
- 11.4. Reading and Writing to Files
- 11.5. Working with File Permissions
- 11.6. Copying, Renaming, and Deleting Files
- 11.7. Working with Directories
- 11.8. Building a Text Editor
- 11.9. Summary
- 11.10. Exercise
- 12. Introducing Databases and SQL
-
13. Retrieving Data from MySQL with PHP
- 13.1. Setting Up the Book Club Database
-
13.2. Retrieving Data with SELECT
- 13.2.1. Limiting the Number of Rows Returned
- 13.2.2. Sorting Results
- 13.2.3. Using Pattern Matching for Flexible Queries
- 13.2.4. Summarizing Data
- 13.2.5. Eliminating Duplicate Results
- 13.2.6. Grouping Results
- 13.2.7. Pulling Data from Multiple Tables
- 13.2.8. Using Aliases
- 13.2.9. Other Useful MySQL Operators and Functions
-
13.3. Creating a Member Record Viewer
- 13.3.1. Creating the config.php File
- 13.3.2. Creating the common.inc.php File
- 13.3.3. Creating the DataObject Class File
- 13.3.4. Building the Member Class
- 13.3.5. Building the LogEntry Class
- 13.3.6. Creating the view_members.php Script
- 13.3.7. Creating the view_member.php Script
- 13.3.8. Testing the Application
- 13.4. Summary
- 13.5. Exercises
-
14. Manipulating MySQL Data with PHP
- 14.1. Inserting Records
- 14.2. Updating Records
- 14.3. Deleting Records
- 14.4. Building a Member Registration Application
-
14.5. Creating a Members' Area
- 14.5.1. Adding an Authentication Method to the Member Class
- 14.5.2. Enhancing the LogEntry Class to Record Page Views
- 14.5.3. Adding More Common Code
- 14.5.4. Writing the Login Page Script
- 14.5.5. Creating a Logout Function
- 14.5.6. Creating the Pages for the Members' Area
- 14.5.7. Testing the Members' Area
- 14.6. Creating a Member Manager Application
- 14.7. Summary
- 14.8. Exercises
- 15. Making Your Job Easier with PEAR
-
16. PHP and the Outside World
-
16.1. Working with Dates and Times
- 16.1.1. Understanding Timestamps
- 16.1.2. Getting the Current Date and Time
- 16.1.3. Creating Your Own Timestamps
- 16.1.4. Extracting Date and Time Values from a Timestamp
- 16.1.5. Formatting Date Strings
- 16.1.6. Checking Date Values
- 16.1.7. Working with Microseconds
- 16.1.8. DateTime: The Future of PHP Date/Time Handling
- 16.2. Working with HTTP
- 16.3. Getting Information from the Web Server
- 16.4. Sending Email
- 16.5. Summary
- 16.6. Exercises
-
16.1. Working with Dates and Times
- 17. Generating Images with PHP
-
18. String Matching with Regular Expressions
- 18.1. What Is a Regular Expression?
- 18.2. Pattern Matching in PHP
-
18.3. Exploring Regular Expression Syntax
- 18.3.1. Matching Literal Characters
- 18.3.2. Matching Types of Characters Using Character Classes
- 18.3.3. Matching Multiple Characters
- 18.3.4. Greedy and Non-Greedy Matching
- 18.3.5. Using Subpatterns to Group Patterns
- 18.3.6. Referring to Previous Subpattern Matches
- 18.3.7. Matching Alternative Patterns
- 18.3.8. Using Anchors to Match At Specified Positions
- 18.4. Finding Multiple Matches with preg_match_all()
- 18.5. Searching Arrays with preg_grep()
- 18.6. Replacing Text
- 18.7. Altering Matching Behavior with Pattern Modifiers
- 18.8. Splitting a String with a Regular Expression
- 18.9. Summary
- 18.10. Exercises
-
19. Working with XML
- 19.1. What Is XML?
-
19.2. XML Document Structure
- 19.2.1. Major Parts of an XML Document
- 19.2.2. XML Syntax Rules
- 19.2.3. Using XML Elements and Attributes
- 19.2.4. Valid XML Documents: DTDs and XSDs
- 19.2.5. XHTML: An Example of DTDs in Action
- 19.2.6. The DTDs for XHTML
- 19.2.7. Referencing DTDs
- 19.2.8. Specifying Namespaces
- 19.2.9. Creating an XHTML Document
- 19.3. Reading XML Documents with PHP
- 19.4. Writing and Manipulating XML Documents with PHP
- 19.5. Doing XML the Easy Way with SimpleXML
- 19.6. Working with XSL and XSLT
- 19.7. Summary
- 19.8. Exercises
-
20. Writing High-Quality Code
- 20.1. Writing Modular Code
- 20.2. Using Coding Standards for Consistency
- 20.3. Documenting Your Code
- 20.4. Checking Input and Encoding Output
-
20.5. Handling Errors
- 20.5.1. Understanding Error Levels
- 20.5.2. Triggering Errors
- 20.5.3. Controlling Where Error Messages Are Sent
- 20.5.4. Logging Your Own Error Messages
- 20.5.5. Letting Your Script Handle Errors
- 20.5.6. Fine-Tuning Error Reporting
- 20.5.7. Using Exception Objects to Handle Errors
- 20.5.8. Throwing Exceptions
- 20.5.9. Catching Exceptions
- 20.5.10. Creating Your Own Exception Classes
- 20.6. Separating Application Logic from Presentation Logic
- 20.7. Automated Code Testing with PHPUnit
- 20.8. Summary
- 20.9. Exercises
-
A. Solutions to Exercises
- A.1. Chapter 2
- A.2. Chapter 3
- A.3. Chapter 4
- A.4. Chapter 5
- A.5. Chapter 6
- A.6. Chapter 7
- A.7. Chapter 8
- A.8. Chapter 9
- A.9. Chapter 10
- A.10. Chapter 11
- A.11. Chapter 12
- A.12. Chapter 13
- A.13. Chapter 14
- A.14. Chapter 15
- A.15. Chapter 16
- A.16. Chapter 17
- A.17. Chapter 18
- A.18. Chapter 19
- A.19. Chapter 20
- B. Configuring PHP
- C. Alternatives to MySQL
- D. Using PHP from the Command Line
Product information
- Title: Beginning PHP 5.3
- Author(s):
- Release date: October 2009
- Publisher(s): Wrox
- ISBN: 9780470413968
You might also like
book
PHP and MySQL™ Phrasebook
gives you the code you need to complete your web programming projects quickly and effectively in …
book
Expert PHP and MySQL®
Best practices and expert techniques for even the most demanding MySQL-driven PHP applications PHP is the …
book
PHP 7 Programming Blueprints
Learn how to exploit the impressive power of PHP 7 with this collection of practical project …
book
PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition
It hasn't taken Web developers long to discover that when it comes to creating dynamic, database-driven …