/[cvs]/nfo/php/libs/com.newsblob.phphtmllib/examples/example1.php
ViewVC logotype

Contents of /nfo/php/libs/com.newsblob.phphtmllib/examples/example1.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Thu Jan 30 03:29:43 2003 UTC (21 years, 6 months ago) by jonen
Branch: MAIN
Branch point for: no_vendor_tag
Initial revision

1 <?php
2
3 /**
4 * This example illustrates how to use the
5 * HTMLPageClass to build a complete html
6 * page.
7 *
8 *
9 * $Id: example1.php,v 1.6 2002/09/26 21:29:06 hemna Exp $
10 *
11 * @author Walter A. Boring IV <waboring@buildabetterweb.com>
12 * @package phpHtmlLib
13 * @subpackage examples
14 * @version 2.0.0
15 *
16 */
17
18 /**
19 * Include the phphtmllib libraries
20 * All subsequent examples will use the
21 * inlude_once("includes.inc"); which contains
22 * the following 2 lines
23 */
24 //$phphtmllib = $_SERVER["DOCUMENT_ROOT"] . "/phphtmllib";
25 $phphtmllib = "/home/max/dev/netfrag.org/nfo/php/libs/com.newsblob.phphtmllib";
26 include_once("$phphtmllib/includes.inc");
27
28
29 //create the page object
30
31 //the first parameter is the title of the page.
32 //this will automatically get placed inside the <title>
33 //inside the head.
34
35 //we want XHTML output instead of HTML
36 //IF you want HTML output, then just leave off the
37 //2nd parameter to the constructor.
38
39 //Be default, phpHtmlLib will nicely indent all of the output
40 //of the html source, to make it easy to read. If you want
41 //all of the html source output to be left justified, then
42 //pass INDENT_LEFT_JUSTIFY as the 3rd parameter.
43 $page = new HTMLPageClass("phpHtmlLib Example 1 - Hello World",
44 XHTML_TRANSITIONAL);
45
46 //if you want phphtmllib to render the
47 //output as viewable source code
48 //then add ?debug=1 to the query string to this script
49 $page->set_text_debug( $_GET["debug"] );
50
51
52 //add the obligitory hello world
53 //calling the add method will add the object
54 //into the page. It will get rendered when
55 //you call the HTMLPageClass' render() method.
56 $page->add( html_span(NULL, "hello world"), html_br(2) );
57
58 //note the calls to the 2 helper functions
59 //html_span() and html_br() These are wrapper
60 //functions for constructing tags and adding common
61 //attributes, along with content.
62 // All of the helper functions live in phphtmllib/tag_utils
63 //html_span() takes a string as the first parameter
64 //which will set the class="something" attribute
65 //any n number of parameters after that will be
66 //added to the content of the tag.
67
68 //html_br() builds a <br> tag. The parameter is
69 //how many <br>'s to build.
70
71
72 //lets add a simple link to this script
73 //and turn debugging on
74 $page->add( html_a($_SERVER["PHP_SELF"]."?debug=1", "Show Debug source") );
75
76
77 //this will render the entire page
78 //with the content you have added
79 //wrapped inside all the required
80 //elements for a complete HTML/XHTML page.
81 //NOTE: all the objects in phphtmllib have
82 // the render() method. So you can call
83 // render on any phphtmlib object.
84 print $page->render();
85 ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed