PHP and MySQL Web Development, 3/e

Luke Welling, Laura Thomson

  • 出版商: SAMS
  • 出版日期: 2005-01-01
  • 售價: $2,010
  • 貴賓價: 9.5$1,910
  • 語言: 英文
  • 頁數: 984
  • 裝訂: Paperback
  • ISBN: 0672326728
  • ISBN-13: 9780672326721
  • 相關分類: MySQLPHPSQL
  • 已過版

買這商品的人也買了...

相關主題

商品描述

Description:

We've taken the best and made it even better. The third edition of the best-selling PHP and MySQL Web Development has been updated to include material and code on MySQL 5, PHP 5 and on PHPs object model and validation. Through a clear, practical approach, you will learn to develop secure, dynamic websites by integrating and implementing the PHP scripting language and the MySQL database system. Real-world examples and working sample projects will give you a strong foundation on which to start building your own websites, complete with features such as SSL, shopping carts and payment systems. The accompanying CD includes the source code from each example in the book, the entire book in PDF format, and source code and binaries for PHP 5, MySQL 5 and Apache. Readers have called PHP and MySQL Web Development call it the best technical book they've ever read, but don't take their word for it. Find out for yourself!

 

Table of Contents:

Introduction.

I. Using PHP

1. PHP Crash Course.

    Using PHP.

    Creating a Sample Application: Bob’s Auto Parts.

      Creating the Order Form.

      Processing the Form.

    Embedding PHP in HTML.

      Use of PHP Tags.

      PHP Tag Styles.

      PHP Statements.

      Whitespace.

      Comments.

    Adding Dynamic Content.

      Calling Functions.

      Using the date() Function.

    Accessing Form Variables.

      Form Variables.

      String Concatenation.

      Variables and Literals.

    Understanding Identifiers.

    Creating User-Declared Variables.

    Assigning Values to Variables.

    Examining Variable Types.

      PHP’s Data Types.

      Type Strength.

      Type Casting.

      Variable Variables.

    Declaring and Using Constants.

    Understanding Variable Scope.

    Using Operators.

      Arithmetic Operators.

      String Operators.

      Assignment Operators.

      Comparison Operators.

      Logical Operators.

      Bitwise Operators.

      Other Operators.

    Using Operators: Working Out the Form Totals.

    Understanding Precedence and Associativity: Evaluating Expressions.

    Using Variable Functions.

      Testing and Setting Variable Types.

      Testing Variable Status.

      Reinterpreting Variables.

    Implementing Control Structures.

    Making Decisions with Conditionals.

      if Statements.

      Code Blocks.

      else Statements.

      elseif Statements.

      switch Statements.

      Comparing the Different Conditionals.

    Repeating Actions Through Iteration.

      while Loops.

      for and foreach Loops.

      do..while Loops.

    Breaking Out of a Control Structure or Script.

    Employing Alternative Control Structure Syntax.

    Using declare.

    Next: Saving the Customer’s Order.

2. Storing and Retrieving Data.

    Saving Data for Later.

    Storing and Retrieving Bob’s Orders.

    Processing Files.

    Opening a File.

      Choosing File Modes.

      Using fopen() to Open a File.

      Opening Files Through FTP or HTTP.

      Addressing Problems Opening Files.

    Writing to a File.

      Parameters for fwrite().

      File Formats.

    Closing a File.

    Reading from a File.

      Opening a File for Reading: fopen().

      Knowing When to Stop: feof().

      Reading a Line at a Time: fgets(), fgetss(), and fgetcsv().

      Reading the Whole File: readfile(), fpassthru(), and file().

      Reading a Character: fgetc().

      Reading an Arbitrary Length: fread().

    Using Other Useful File Functions.

      Checking Whether a File Is There: file_exists().

      Determining How Big a File Is: filesize().

      Deleting a File: unlink().

      Navigating Inside a File: rewind(), fseek(), and ftell().

    Locking Files.

    Doing It a Better Way: Database Management Systems.

      Problems with Using Flat Files.

      How RDBMSs Solve These Problems.

    Further Reading.

    Next.

3. Using Arrays.

    What Is an Array?

    Numerically Indexed Arrays.

      Initializing Numerically Indexed Arrays.

      Accessing Array Contents.

      Using Loops to Access the Array.

    Arrays with Different Indices.

      Initializing an Array.

      Accessing the Array Elements.

      Using Loops.

    Array Operators.

    Multidimensional Arrays.

    Sorting Arrays.

      Using sort().

      Using asort() and ksort() to Sort Arrays.

      Sorting in Reverse.

    Sorting Multidimensional Arrays.

      User-Defined Sorts.

      Reverse User Sorts.

    Reordering Arrays.

      Using shuffle().

      Using array_reverse().

    Loading Arrays from Files.

    Performing Other Array Manipulations.

      Navigating Within an Array: each(), current(), reset(), end(), next(), pos(), and prev().

      Applying Any Function to Each Element in an Array: array_walk().

      Counting Elements in an Array: count(), sizeof(), and array_count_values().

      Converting Arrays to Scalar Variables: extract().

    Further Reading.

    Next.

4. String Manipulation and Regular Expressions.

    Creating a Sample Application: Smart Form Mail.

    Formatting Strings.

      Trimming Strings: chop(), ltrim(), and trim().

      Formatting Strings for Presentation.

      Formatting Strings for Storage: addslashes() and stripslashes().

    Joining and Splitting Strings with String Functions.

      Using explode(), implode(), and join().

      Using strtok().

      Using substr().

    Comparing Strings.

      Performing String Ordering: strcmp(), strcasecmp(), and strnatcmp().

      Testing String Length with strlen().

    Matching and Replacing Substrings with String Functions.

      Finding Strings in Strings: strstr(), strchr(), strrchr(), and stristr().

      Finding the Position of a Substring: strpos() and strrpos().

      Replacing Substrings: str_replace() and substr_replace().

    Introducing Regular Expressions.

      The Basics.

      Character Sets and Classes.

      Repetition.

      Subexpressions.

      Counted Subexpressions.

      Anchoring to the Beginning or End of a String.

      Branching.

      Matching Literal Special Characters.

      Reviewing the Special Characters.

      Putting It All Together for the Smart Form.

    Finding Substrings with Regular Expressions.

    Replacing Substrings with Regular Expressions.

    Splitting Strings with Regular Expressions.

    Comparing String Functions and Regular Expression Functions.

    Further Reading.

    Next.

5. Reusing Code and Writing Functions.

    Reusing Code.

      Cost.

      Reliability.

      Consistency.

    Using require() and include().

      require().

      Filename Extensions and require().

      PHP Tags and require().

    Using require() for Website Templates.

      Using include().

      Using require_once() and include_once().

      Using auto_prepend_file and auto_append_file.

    Using Functions in PHP.

      Calling Functions.

      Calling an Undefined Function.

      Understanding Case and Function Names.

    Understanding Why You Should Define Your Own Functions.

    Examining Basic Function Structure.

      Naming Your Function.

    Using Parameters.

    Understanding Scope.

    Passing by Reference Versus Passing by Value.

    Returning from Functions.

    Returning Values from Functions.

      Code Blocks.

    Implementing Recursion.

    Further Reading.

    Next.

6. Object-Oriented PHP.

    Understanding Object-Oriented Concepts.

      Classes and Objects.

      Polymorphism.

      Inheritance.

    Creating Classes, Attributes, and Operations in PHP.

      Structure of a Class.

      Constructors.

      Destructors.

    Instantiating Classes.

    Using Class Attributes.

    Controlling Access with private and public.

    Calling Class Operations.

    Implementing Inheritance in PHP.

      Controlling Visibility Through Inheritance with private and protected.

      Overriding.

      Preventing Inheritance and Overriding with final.

      Understanding Multiple Inheritance.

      Implementing Interfaces.

    Designing Classes.

    Writing the Code for Your Class.

    Understanding Advanced and New Object-Oriented Functionality in PHP.

      Note: PHP4 Versus PHP5.

      Using Per-Class Constants.

      Implementing Static Methods.

      Checking Class Type and Type Hinting.

      Cloning Objects.

      Using Abstract Classes.

      Overloading Methods with __call().

      Using __autoload().

      Implementing Iterators and Iteration.

      Converting Your Classes to Strings.

      Using the Reflection API.

    Next.

7. Exception Handling.

    Exception Handling Concepts.

    The Exception Class.

    User-Defined Exceptions.

    Exceptions in Bob’s Auto Parts.

    Exceptions and PHP’s Other Error Handling Mechanisms.

    Further Reading.

    Next.

II. Using MySQL

8. Designing Your Web Database.

    Relational Database Concepts.

      Tables.

      Columns.

      Rows.

      Values.

      Keys.

      Schemas.

      Relationships.

    How to Design Your Web Database.

      Think About the Real-World Objects You Are Modeling.

      Avoid Storing Redundant Data.

      Use Atomic Column Values.

      Choose Sensible Keys.

      Think About the Questions You Want to Ask the Database.

      Avoid Designs with Many Empty Attributes.

      Summary of Table Types.

    Web Database Architecture.

      Architecture.

    Further Reading.

    Next.

9. Creating Your Web Database.

    Using the MySQL Monitor.

    Logging In to MySQL.

    Creating Databases and Users.

      Creating the Database.

    Setting Up Users and Privileges.

    Introducing MySQL’s Privilege System.

      Principle of Least Privilege.

      User Setup: The GRANT Command.

      Types and Levels of Privileges.

      The REVOKE Command.

      Examples Using GRANT and REVOKE.

    Setting Up a User for the Web.

      Logging Out as root.

    Using the Right Database.

    Creating Database Tables.

      Understanding What the Other Keywords Mean.

      Understanding the Column Types.

      Looking at the Database with SHOW and DESCRIBE.

      Creating Indexes.

      A Note on Table Types.

    Understanding MySQL Identifiers.

    Choosing Column Data Types.

      Numeric Types.

    Further Reading.

    Next.

10. Working with Your MySQL Database.

    What Is SQL?

     Inserting Data into the Database.

    Retrieving Data from the Database.

      Retrieving Data with Specific Criteria.

      Retrieving Data from Multiple Tables.

      Retrieving Data in a Particular Order.

      Grouping and Aggregating Data.

      Choosing Which Rows to Return.

      Using Subqueries.

    Updating Records in the Database.

    Altering Tables After Creation.

    Deleting Records from the Database.

    Dropping Tables.

    Dropping a Whole Database.

    Further Reading.

    Next.

11. Accessing Your MySQL Database from the Web with PHP.

    How Web Database Architectures Work.

    Querying a Database from the Web.

    Checking and Filtering Input Data.

    Setting Up a Connection.

    Choosing a Database to Use.

    Querying the Database.

    Retrieving the Query Results.

    Disconnecting from the Database.

    Putting New Information in the Database.

    Using Prepared Statements.

    Using Other PHP-Database Interfaces.

    Using a Generic Database Interface: PEAR DB.

    Further Reading.

    Next.

12. Advanced MySQL Administration.

    Understanding the Privilege System in Detail.

      The user Table.

      The db and host Tables.

      The tables_priv and columns_priv Tables.

      Access Control: How MySQL Uses the Grant Tables.

      Updating Privileges: When Do Changes Take Effect?

    Making Your MySQL Database Secure.

      MySQL from the Operating System’s Point of View.

      Passwords.

      User Privileges.

      Web Issues.

    Getting More Information About Databases.

      Getting Information with SHOW.

      Getting Information About Columns with DESCRIBE.

      Understanding How Queries Work with EXPLAIN.

    Speeding Up Queries with Indexes.

    Optimizing Your Database.

      Design Optimization.

      Permissions.

      Table Optimization.

      Using Indexes.

      Using Default Values.

      Other Tips.

    Backing Up Your MySQL Database.

    Restoring Your MySQL Database.

    Implementing Replication.

      Setting Up the Master.

      Performing the Initial Data Transfer.

      Setting Up the Slave or Slaves.

    Further Reading.

    Next.

13. Advanced MySQL Programming.

    The LOAD DATA INFILE Statement.

    Storage Engines.

    Transactions.

      Understanding Transaction Definitions.

      Using Transactions with InnoDB.

    Foreign Keys.

    Stored Procedures.

      Basic Example.

      Local Variables.

      Cursors and Control Structures.

    Further Reading.

    Next.

III. E-COMMERCE AND SECURITY.

14. Running an E-commerce Site.

    Deciding What You Want to Achieve.

    Considering the Types of Commercial Websites.

      Publishing Information Using Online Brochures.

      Taking Orders for Goods or Services.

      Providing Services and Digital Goods.

      Adding Value to Goods or Services.

      Cutting Costs.

    Understanding Risks and Threats.

      Crackers.

      Failure to Attract Sufficient Business.

      Computer Hardware Failure.

      Power, Communication, Network, or Shipping Failures.

      Extensive Competition.

      Software Errors.

      Evolving Governmental Policies and Taxes.

      System Capacity Limits.

    Deciding on a Strategy.

    Next.

15. E-commerce Security Issues.

    How Important Is Your Information?

    Security Threats.

      Exposure of Confidential Data.

      Loss or Destruction of Data.

      Modification of Data.

      Denial of Service.

      Errors in Software.

      Repudiation.

    Usability, Performance, Cost, and Security.

    Security Policy Creation.

    Authentication Principles.

    Authentication.

    Encryption Basics.

    Private Key Encryption.

    Public Key Encryption.

    Digital Signatures.

    Digital Certificates.

    Secure Web Servers.

    Auditing and Logging.

    Firewalls.

    Data Backups.

      Backing Up General Files.

      Backing Up and Restoring Your MySQL Database.

    Physical Security.

 &nbs