tailieunhanh - PHP 5/MySQL Programming- P58

PHP 5/MySQL Programming- P58:computer programming has often been seen as a difficult and arcane skill. Programming languages are difficult and complicated, out of the typical person’s reach. However, the advent of the World Wide Web has changed that to some extent. It’s reasonably easy to build and post a Web page for the entire world to see. The language of the Web is reasonably simple, and numerous applications are available to assist in the preparation of static pages | 263 Creating the Bottom of the Page The bottom of the page is very easy. I just built some standard page-ending HTML and added it to thePage. function buildBottom builds the bottom of a generic web page temp HERE body html HERE this- addText temp end buildBottom Adding Headers and Generic Tags The tag method is very useful because it allows you to surround any text with any HTML tag or even an XML tag you wish. The gTag function is similar but doesn t store anything to thePage. To simplify my coding I wrote gTag first. This method creates a temporary variable containing the tag name and contents nicely formatted. One of the things I didn t like about is how horrible the resulting HTML code looked. I want code produced by my programs to look as good as code produced directly by me. The tag method calls gTag and adds the results with addText . If I make a change to the gTag function I won t have to remember to make the same change in tag . It s good to avoid rewriting code when you can. general tag functions Chapter 7 Writing Programs with Objects function gTag tagName contents given any tag surrounds contents with tag improve so tag can have attributes returns tag but does not add it to page temp tagName n temp . . contents . n temp . tagName n return temp end tag function tag tagName contents given any tag surrounds contents with tag 264 PHP 5 MySQL Programming for the Absolute Beginner improve so tag can have attributes temp this- gTag tagName contents this- addText temp end tag header functions function h1 stuff this- tag h1 stuff end hl function h2 stuff this- tag h2 stuff end h2 function h3 stuff this- tag h3 stuff end h3 function h4 stuff this- tag h4 stuff end h4 function h5 stuff this- tag h5 stuff end h5 function h6 stuff this- tag h6 stuff end h6 The h1 through h6 methods are all wrappers around the tag method that simply provide shortcuts for these very common HTML tags. Of course you could add shortcuts for all your other favorite tags. Creating .