File: classes/Html.php

Recommend this page to a friend!
  Classes of Brett Dutton  >  Rotate Image  >  classes/Html.php  >  Download  
File: classes/Html.php
Role: Class source
Content type: text/plain
Description: Utility Class to assist with generating Html
Class: Rotate Image
Display random images from a list in rotation
Author: By
Last change:
Date: 13 years ago
Size: 1,290 bytes
 

Contents

Class file image Download
<?
/**
 * Html - Helper class to generate a few HTML entities
 * Author - Brett Dutton
 */
class Html {
   
/** Adds the HTML Script tags to the provided javascript string and returns
     ** the resulting HTML
     ** @param $str The javascript string
     **/
   
function javaScript ( $str ) {
        return (
"<script type=\"text/javascript\" language=\"JavaScript\">\n$str\n</script>\n" );
    }

   
/** Creates and returns the HTML required to display an image
     ** @param $s The src of the image
     ** @param $xtra Any extra attributes
     **/
   
function img ( $s, $xtra=NULL ) {
       
$a = "<img src=\"$s\"";
        if (
$xtra != NULL && $xtra != "" ) $a .= " " . $xtra;
       
$a .= ">";
        return (
$a );
    }

   
/**
     ** function to create the text for href output
     ** @param $ref URL
     ** @param $str The image or text for this link
     ** @param $extra any extra parameters
     **/
   
function hRef ( $ref=NULL, $str=NULL, $extra=NULL ) {
        if (
$ref == NULL || $str == NULL ) return ( "&nbsp;" );
        else {
           
$a = "<a href=\"$ref\"";
            if (
$extra != NULL && $extra != "" ) $a .= " $extra";
           
$a .= ">$str</a>";
            return (
$a );
        }
    }
}
?>


For more information send a message to info at phpclasses dot org.