tailieunhanh - OBJECT-ORIENTED PHP Concepts, Techniques, and Code- P3
OBJECT-ORIENTED PHP Concepts, Techniques, and Code- P3: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. | 1 WHAT A TANGLED WEB WE WEAVE Creating a web page ain t what it used to be. Setting up a website today usually means incorporating numerous technologies among them X HTML CSS JavaScript SQL and a server-side scripting language. But that s not all a web page also runs within a browser. There are several different browsers of course and each behaves differently. Not only that but different versions of the same browser can act differently and even the same version of the same browser can t be relied upon to behave the same when running on different operating systems with different hardware different screen resolutions and so on. Add to this the various configuration files for the scripting language and the web server for example which also affect the display of a particular web page and you can see that the web developer s lot is not a happy one. It may not be readily apparent that an object-oriented OO approach is a means of simplifying this situation. OO development might be seen as symptomatic of the larger problem. To the embattled web developer an OO approach can appear to be just another complication of what s already a messy business. Do We Really Need Objects The ability of any server-side scripting language to include files within a web page reduces initial work and ongoing maintenance. For instance suppose a website contains a menu at the top of each web page and this menu is identical throughout the site. You could cut and paste the appropriate code into every page but this is both cumbersome and counterproductive. It s much better to write the code once and use a server-side scripting language to insert the menu wherever it s needed. That way should an update be required you can make one change to one file rather than changing many files. This makes site-wide updates much easier. You could summarize this approach as include and reuse don t rewrite. In a sense object-oriented programming OOP is just an extension of this concept. Objects simplify web .
đang nạp các trang xem trước