PHP Object Oriented Solutions ppsx

395 702 0
PHP Object Oriented Solutions ppsx

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

this print for reference only—size & color not accurate spine = 0.911" 392 page count DAVID POWERS In this book you’ll learn how to: Produce code that’s easier to maintain by adopting OOP techniques. Use best practices by implementing basic design patterns. Simplify complex code through encapsulation. Unlock the secrets of the Standard PHP Library. Generate your own news feed using Really Simple Syndication (RSS). P HP is easy to learn and a great way to add dynamic functionality to web sites, such as sending email from online forms and generating database-driven content. But there soon comes a time when you realize you’re writing similar scripts over and over again. By adopting an object-oriented approach, you can avoid the need to reinvent the wheel every time, creating scripts that are reusable, easier to understand, and easier to maintain. The main barrier to object-oriented programming (OOP) is that it’s based on unfamiliar concepts, such as objects, classes, interfaces, encapsulation, and polymorphism. This book strips away the mystique and explains each concept in an approachable and understandable way. It provides a gentle but fast-paced introduction to OOP as it applies to PHP. Another barrier to the adoption of OOP among PHP developers has been the slow migra- tion from PHP 4, which used a radically different—and inferior—object model. Now that PHP 4 has come to the official end of its life, this book concentrates exclusively on using OOP with PHP 5 and 6. So you can be confi- dent that you’re learning skills that won’t be out of date almost as soon as you put the book down. Through a series of practical projects, this book shows how OOP can be used to group related functions in a portable manner. The projects include a validator for fil- tering user input, a class that avoids the need to remember all the esoteric PHP date formatting codes, and an XML generator—everyday requirements for a lot of develop- ers. Although the emphasis is on learning how the code works, if you’re in a hurry, the PHP classes used in the book can be downloaded from the friends of ED web site and incorporated into existing sites with a minimum of effort. The book is aimed at intermediate developers with a good understanding of PHP basics, such as variables, arrays, functions, loops, and conditional statements. It provides the necessary groundwork for advancing on to using an object-oriented framework, such as the Zend Framework, and taking your PHP coding skills to the next level. Powers CYAN YELLOW MAGENTA BLACK PHP OBJECT-ORIENTED SOLUTIONS Understand basic OOP concepts, such as inheritance, encapsulation, and polymorphism. Extend core PHP classes. Design and create your own classes for PHP 5 and 6. Also Available US $36.99 Mac/PC compatible www.friendsofed.com http://foundationphp.com/ SHELVING CAT EG OR Y 1. PHP Available from Apress ISBN 978-1-4302-1011-5 9 781430 210115 5 3 6 9 9 [...]... of PHP 5.2 OOP since PHP 5 PHP s handling of objects was completely rewritten in PHP 5 to improve performance and conform to standards common to other object- oriented languages Aside from a long list of new features, the biggest change from PHP 3 and 4 is the way objects and their properties are handled Take the following line of code: $objectB = $objectA; In PHP 3 and 4, this makes a copy of $objectA... S Let’s get things straight right from the start: PHP (PHP Hypertext Preprocessor) is not an object- oriented language, but it does have extensive object- oriented features These underwent comprehensive revision and enhancement when PHP 5 was released in July 2004, and the PHP 5 object- oriented programming (OOP) model remains essentially unchanged in PHP 6 The purpose of this book is to help you leverage... existing scripts So, when PHP 5 was released in July 2004, the way classes and objects work in PHP was changed radically PHP 4 objects are incompatible with those designed for PHP 5 The good news is that, apart from a few advanced features beyond the scope of this book, the way PHP 6 handles objects is identical to PHP 5 All the code in this book is designed to work in both PHP 5 and PHP 6 To ensure full... minimum of PHP 5, and preferably PHP 5.2 or 5.3 It has also been designed to work in PHP 6 The code will not work in PHP 4, nor will any support be provided for converting it to PHP 4 Even though at the time of publication, it’s estimated that more than half of all PHP- driven websites still run on PHP 4, all support for PHP 4 officially ended on August 8, 2008 PHP 4 is dead Long live PHP 5 (and PHP 6 when... $objectA and stores it as $objectB Both objects then act independently of each other; changes made to $objectA don’t affect $objectB, and vice versa This is known as copying by value and is the way PHP handles variables In short, PHP 3 and 4 treated objects like any other variable Since PHP 5, objects are treated differently from other variables Instead of making a copy of $objectA, the previous line... Elements of Reusable Object- Oriented Software by Gamma, Helm, Johnson, and Vlissides (Addison-Wesley, ISBN13: 978-0201633610), affectionately known as the “Gang of Four (GoF) book.” 12 10115ch01.qxd 7/10/08 1:12 PM Page 13 W H Y O B J E C T- O R I E N T E D P H P ? How OOP has evolved in PHP As I said before, PHP is not an object- oriented language In fact, support for OOP wasn’t added until PHP 3 Unfortunately,... prefixed with Pos_ (for PHP Object- Oriented Solutions) , so the class in Chapter 4 will be called Pos_Validator When you want to use any of the class’s properties or methods, you need to create an instance of the class by using the new keyword like this: $val = new Pos_Validator(); This creates an object called $val As you can see, it looks just like an ordinary PHP variable, so what is an object? In this particular... an object is and how it differs from a class What terms such as encapsulation, inheritance, and polymorphism really mean How the object- oriented model has developed in PHP Which tools make it easier to work with classes in PHP I don’t intend to bombard you with dense theory The emphasis will be on gaining practical results with a minimum of effort If you’re lazy or in a hurry, you can just use the PHP. .. flyingtigerwebdesign.com), who suggested I should write Powers Object- Oriented PHP Actually, he phrased it rather differently If you take the initial letters of the suggested title, you’ll get the drift But Steve had an important point: he felt that books on object- oriented programming (OOP) frequently assumed too much prior knowledge or weren’t easily adaptable to PHP in a practical way If you like what you find... haven’t yet made the switch from PHP 4, now is the time to do it Who should read this book If you develop in PHP, but haven’t yet got your feet wet with OOP, this is the book for you No previous knowledge of OOP is necessary: Chapter 1 covers the basic theory and explains how OOP fits into PHP; Chapter 2 then goes into the mechanics of writing objectoriented code in PHP The remaining seven chapters . 210115 5 3 6 9 9

Ngày đăng: 08/07/2014, 08:21

Từ khóa liên quan

Mục lục

  • PHP Object-Oriented Solutions

  • CONTENTS AT A GLANCE

  • CONTENTS

  • ABOUT THE AUTHOR

  • ABOUT THE TECHNICAL REVIEWER

  • ACKNOWLEDGMENTS

  • INTRODUCTION

    • Who should read this book

    • Using the download code

      • Understanding the file numbering system

      • What to do if things go wrong

      • Layout conventions

      • WHY OBJECT-ORIENTED PHP?

        • Understanding basic OOP concepts

          • 1

          • How OOP evolved

          • Using classes and objects

          • 1

          • Protecting data integrity with encapsulation

          • 1

          • Polymorphism is the name of the game

          • Extending classes through inheritance

          • 1

          • Using best practice

Tài liệu cùng người dùng

Tài liệu liên quan