TAILIEUCHUNG - OBJECT-ORIENTED PHP Concepts, Techniques, and Code- P4

OBJECT-ORIENTED PHP Concepts, Techniques, and Code- P4:A number of years ago, before I started using PHP, I created dynamic web pages using C. This really wasn’t too different from some of the other options available at the time, though it seems almost unthinkable now. Creating a dynamic page meant outputting HTML from your script and recompiling that script if any changes needed to be made. | 3 OBJECT-ORIENTED FEATURES NEW TO PHP 5 PHP 3 was released in mid-1998. Some basic object-oriented OO capabilities were included more or less as an afterthought to provide new ways of accessing arrays. 1 No significant changes were made to the object model when version 4 was released in mid-2000. The basics of object-oriented programming OOP were there you could create a class and single inheritance was supported. With the release of PHP 5 in 2004 there was plenty of room for improving PHP s OO capabilities. At this point Java the most popular OO language to date had already been around for almost 10 years. Why did it take PHP so long to become a full-fledged OO language The short answer is because PHP is principally a web development language and the pressures of web development have only recently pushed it in this direction. 1 See Zeev Suraski Object-Oriented Evolution of PHP available at webdev Article 10007 0 page 1. Accessed March 27 2006. Support for objects has been grafted onto the language you can choose to use objects or simply revert to procedural programming. That PHP is a hybrid language should be viewed as something positive not as a disadvantage. There are some situations where you will simply want to insert a snippet of PHP and other situations where you will want to make use of its OO capabilities. As I have already argued in Chapter 1 in some cases an OO solution is the only solution. PHP 5 recognizes this fact and incorporates a full-blown object model consolidating PHP s position as the top server-side scripting language. Like Chapter 2 this will be a chapter of broad strokes. I ll give a general overview of how the object model has been improved and then I ll get into the details using concrete examples in later chapters. I ll also address the issue of backward compatibility. Access Modifiers Chapter 2 identified access modifiers as an essential element of an OO language. PHP 5 gives us everything we would expect in this area. In .

TỪ KHÓA LIÊN QUAN
TÀI LIỆU HOT