O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

PHP: The Good Parts

Book Description

Get past all the hype about PHP and dig into the real power of this language. This book explores the most useful features of PHP and how they can speed up the web development process, and explains why the most commonly used PHP elements are often misused or misapplied. You'll learn which parts add strength to object-oriented programming, and how to use certain features to integrate your application with databases.

Written by a longtime member of the PHP community, PHP: The Good Parts is ideal for new PHP programmers, as well as web developers switching from other languages.

  • Become familiar with PHP's basic syntax, variables, and datatypes
  • Learn how to integrate the language with web pages
  • Understand how to use strings, arrays, and PHP's built-in functions
  • Discover the advantages of using PHP as an object-oriented language
  • Explore how PHP interacts with databases, such as SQLite and MySQL
  • Learn input- and output-handling best practices to prevent security breaches

Table of Contents

  1. Dedication
  2. A Note Regarding Supplemental Files
  3. Foreword
  4. Preface
    1. Conventions Used in This Book
    2. Using Code Examples
    3. How to Contact Us
    4. Safari® Books Online
    5. Acknowledgments
  5. 1. The Good Parts
    1. Why PHP?
      1. A Brief History of PHP
      2. PHP’s Place in the World
      3. What Is PHP?
      4. What Has Been Accomplished with PHP?
    2. Basic PHP Setup
  6. 2. Casing the Joint
    1. Whitespace, Comments, and Basic Syntax
    2. Variables: Data Types, Loose Typing, and Scope
    3. Defined Constants
    4. Expressions
    5. Decisions, Decisions (Flow Control)
      1. If...Else...
      2. Switch...Case...
      3. While...
      4. For
    6. Integration with Web Pages
      1. Cookies
      2. Sessions
      3. $_GET
      4. $_POST
      5. $_REQUEST
  7. 3. Functions (Doing It Once)
    1. Parameter Passing
    2. Default Parameters
    3. Passing by Value Versus Passing by Reference
    4. Include and Require
    5. Built-In Functions Versus UDFs
  8. 4. Strings
    1. What Is a String?
    2. You Can Quote Me
    3. String Functions (Best of)
      1. String Trimmings
      2. Character Case Management
      3. String Content Searching
      4. String Modification
  9. 5. Arrays
    1. Indexed Arrays
    2. Associative Arrays
    3. Arrays from Another Dimension
    4. Arrays Can Be Dynamic
    5. Traversing Arrays
    6. Array Functions (Best of)
      1. Sorting Arrays
      2. Math-Type Functions
      3. Array Potpourri
  10. 6. Objects
    1. Putting It into Practice
    2. Magic Methods
    3. $this
    4. Objects in Action
    5. Public, Protected, and Private
    6. Getters and Setters
  11. 7. Database Interaction
    1. MySQLi Object Interface
    2. Retrieving Data for Display
    3. PHP Data Objects
    4. PDO Prepared Statements
    5. Data Management on the Cheap
      1. SQLite
    6. File Management As a Database Alternative
  12. 8. PHP and Friends
    1. Email/SMS Generation
    2. PDF Generation
      1. Constructor Method and Basic Document Options
      2. Adding Document Headers and Footers
      3. Adding Images and Links
      4. Adding a Watermark
      5. Dynamic PDFs and Table Display
    3. Graphical Reports Generation
      1. Pie Charts
      2. Bar Charts
      3. Captchas
  13. 9. PHP Security
    1. Data Validation
    2. Escape Output
    3. Cross-Site Scripting (XXS) and SQL Injection
    4. Password Encryption Security
    5. Security Tips
  14. 10. PHP 5.3 Good Parts
    1. Namespaces
    2. Closures (Anonymous Functions)
    3. NOWDOC
    4. goto Operator
    5. DateTime and DateTimeZone Classes
    6. Additional 5.3 Features
  15. 11. Advanced Goodness
    1. Regular Expressions
      1. String Matching
      2. String Substituting
      3. String Splitting
    2. SimpleXML
    3. Integrated Development Environments
      1. Komodo by ActiveState
      2. Zend Studio for Eclipse
      3. PhpED by NuSphere
    4. Primary Websites
      1. php.net
      2. zend.com
      3. devzone.zend.com
      4. phparch.com
      5. PHP/Web Conferences
  16. A. The Bad Parts
    1. goto
    2. Function Naming and Parameter Order
    3. Loose Typing
    4. Register Globals
    5. Is That All?
  17. Index
  18. About the Author
  19. Colophon
  20. Copyright