Object-Oriented Programming with PHP5
|Also available on:|
- General OOP concepts explained
- Implement Design Patterns in your applications and solve common OOP Problems
- Take full advantage of native built-in objects
- Test your code by writing unit tests with PHPUnit
Book DetailsLanguage : English
Paperback : 272 pages [ 235mm x 191mm ]
Release Date : December 2007
ISBN : 1847192564
ISBN 13 : 9781847192561
Author(s) : Hasin Hayder
Topics and Technologies : All Books, Web Development, Open Source, PHP
Table of Contents
Chapter 1: OOP vs. Procedural Programming
Chapter 2: Kick-Starting OOP
Chapter 3: More OOP
Chapter 4: Design Patterns
Chapter 5: Reflection and Unit Testing
Chapter 6: Standard PHP Library
Chapter 7: Database in an OOP Way
Chapter 8: Cooking XML with OOP
Chapter 9: Building Better with MVC
Download the code and support files for this book.
Please let us know if you have found any errors not listed on this list by completing our errata submission form. Our editors will check them and add them to this list. Thank you.
Errata- 4 submitted: last submission 11 Nov 2013
Errata type: Others | Page number: 13 | Errata date: 28 Apr 08
In the paragraph 'dissection of an object', data structure' is repeated twice
Errata type: Typo | Page number: 22 | Errata date: 13 Nov 08
The PHP code fragment that reads $emailer = new emailer(); should read $emailer = new Emailer();
Errata type: code | Page number: 60 | Errata date: 28 Apr 08
In the function __wakeup() the last statement $this->staticvars = array(); must be removed
Errata type: Code | Page number: 72
public static function setDriver($driver)
$this->driver = $driver;
//set the driver
It should be
public static function setDriver($driver)
self::$driver = $driver;
//set the driver
What you will learn from this book
- Understand the OOP features of PHP clearly
- Write manageable code
Chapter 1 introduces object-oriented programming and how it fits for PHP. Some benefits of functional programming over procedural programming are highlighted.
In Chapter 2 you learn to create objects and define their properties and methods. Details of classes, properties, and methods follow, along with the scope of methods. This chapter shows you the benefits of using interfaces and a few other basic OOP features in PHP to kick start your journey through OOPing in PHP.
Now that you have got your basics done for OOP in PHP, Chapter 3 helps you to strengthen your base. It helps you to deal with more details and some advanced features. For example you learn about class information functions, using which you can investigate details of any class. This chapter takes you through some handy object-oriented information functions, exception handling, iterators, and storing objects using serialization.
In Chapter 4 you learn some of the Design Patterns and how to implement them in PHP. These are an essential part of OOP and make your code more effective, better performing, and easier to maintain. Sometimes we implement these design patterns in our code without knowing that these solutions are defined by design patterns. Proper usage of the correct pattern can make your code perform better; similarly using them improperly could make your code slower and less efficient.
Chapter 5 focuses on two very important features of object-oriented programming in PHP, reflection and unit testing. PHP5 replaces many old APIs with smarter new ones. One of these is the Reflection API, with which you can reverse or engineer any class or object to figure out its properties and methods. You can invoke those methods dynamically and more. Unit testing is an essential part of good, stable, and manageable application design. We focus on one very popular package, PHPUnit, which is a port of JUnit to PHP. If you follow the guidelines provided in this chapter you will be able to design your own unit tests successfully.
Some built-in objects and interfaces in PHP make life much easier for PHP developers. In Chapter 6 you will learn about the huge object repository named the Standard PHP Library or SPL.
Chapter 7: In this chapter we discuss the improved MySQL API known as MySQLi and take a basic look at PHP Data Objects (PDO), adoDB, and PEAR::MDB2. We take a look at the Active Record pattern in PHP using adoDBâ€™s active record library and the Object-Relational Mapping (ORM) pattern using Propel. We focus on some specific topics that are interesting for PHP developers doing database access the OO way.
In Chapter 8, you learn to process XML with PHP. You get to know about different APIs like the SimpleXML API to read XML and the DOMDocument object to parse and create XML documents.
Chapter 9: In Chapter 4 you learned how design patterns can simplify your daily life in programming by providing you with a common approach for solving problems. One of the most used design patterns for application architecture is the Model-View-Controller (MVC) pattern. In this chapter we discuss the basic structure of MVC frameworks and then introduce you to some of these popular frameworks. Frameworks play a very important role in Rapid Development of PHP applications. You will learn how to build a framework in this chapter, which will also help you to understand object loading, data abstraction layers, and the importance of separation and finally you get a closer look at how applications are done.
Some basic objected-oriented features were added to PHP3; with PHP5 full support for object-oriented programming was added to PHP. Object-oriented programming was basically introduced to ease the development process as well as reduce the time of development by reducing the amount of code needed. OOP can greatly improve the performance of a properly planned and designed program.
This book covers all the general concepts of OOP then shows you how to make use of OOP in PHP5, with the aid of an ample number of examples.
This book will help you to understand the core object-oriented programming concepts with PHP. PHP is one of the most popular languages for web application development, and PHP5 supports OOP very well. This book will help you to master core OOP features in PHP as well as advanced Topics like Design Patterns including Model-View-Controller (MVC), and Unit Testing. It includes suggestions to help you to write good code. Moreover this book provides comprehensive documentation and working examples on the Standard PHP Library (SPL), which are hard to find elsewhere. It will really help you to leverage PHPâ€™s OOP features to write manageable applications with ease.
This book explains how to take full advantage of PHPâ€™s OOP features in simple language. It contains plentiful examples to help you to understand OOP.
Who this book is for
From Beginners to Intermediate Users of PHP5