| 1 |
jonen |
1.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.3 2002/09/10 20:07:30 hemna Exp $ |
| 10 |
|
|
* |
| 11 |
|
|
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
| 12 |
|
|
* @package phpHtmlLib |
| 13 |
|
|
* |
| 14 |
|
|
*/ |
| 15 |
|
|
|
| 16 |
|
|
include_once("localinc.php"); |
| 17 |
|
|
|
| 18 |
|
|
|
| 19 |
|
|
//create the page object |
| 20 |
|
|
//we want XHTML output instead of HTML |
| 21 |
|
|
//IF you want HTML output, then just leave off the |
| 22 |
|
|
//2nd parameter to the constructor. |
| 23 |
|
|
|
| 24 |
|
|
//the first parameter is the title of the page. |
| 25 |
|
|
//this will automatically get placed inside the <title> |
| 26 |
|
|
//inside the head. |
| 27 |
|
|
$page = new HTMLPageClass("First example script", XHTML_TRANSITIONAL); |
| 28 |
|
|
|
| 29 |
|
|
//if you want phphtmllib to render the |
| 30 |
|
|
//output as viewable source code |
| 31 |
|
|
//then add ?debug=1 to the query string to this script |
| 32 |
|
|
$page->set_text_debug( $_GET["debug"] ); |
| 33 |
|
|
|
| 34 |
|
|
|
| 35 |
|
|
//add the obligitory hello world |
| 36 |
|
|
//calling the add method will add the object |
| 37 |
|
|
//into the page. It will get rendered when |
| 38 |
|
|
//you call the HTMLPageClass' render() method. |
| 39 |
|
|
$page->add( html_span(NULL, "hello world"), html_br(2) ); |
| 40 |
|
|
|
| 41 |
|
|
//note the calls to the 2 helper functions |
| 42 |
|
|
//html_span() and html_br() These are wrapper |
| 43 |
|
|
//functions for constructing tags and adding common |
| 44 |
|
|
//attributes, along with content. |
| 45 |
|
|
// All of the helper functions live in phphtmllib/tag_utils |
| 46 |
|
|
//html_span() takes a string as the first parameter |
| 47 |
|
|
//which will set the class="something" attribute |
| 48 |
|
|
//any n number of parameters after that will be |
| 49 |
|
|
//added to the content of the tag. |
| 50 |
|
|
|
| 51 |
|
|
//html_br() builds a <br> tag. The parameter is |
| 52 |
|
|
//how many <br>'s to build. |
| 53 |
|
|
|
| 54 |
|
|
|
| 55 |
|
|
//lets add a simple link to this script |
| 56 |
|
|
//and turn debugging on |
| 57 |
|
|
$page->add( html_a($_SERVER["PHP_SELF"]."?debug=1", "DEBUG ME!") ); |
| 58 |
|
|
|
| 59 |
|
|
|
| 60 |
|
|
//this will render the entire page |
| 61 |
|
|
//with the content you have added |
| 62 |
|
|
//wrapped inside all the required |
| 63 |
|
|
//elements for a complete HTML/XHTML page. |
| 64 |
|
|
//NOTE: all the objects in phphtmllib have |
| 65 |
|
|
// the render() method. So you can call |
| 66 |
|
|
// render on any phphtmlib object. |
| 67 |
|
|
print $page->render(); |
| 68 |
|
|
?> |