PHP/HTML

Материал из .Net Framework эксперт

Перейти к: навигация, поиск

Define function to change HTML text font

<?php
function fontWrap($txt,$fontsize = "12pt") {
  echo "<span style=\"font-size:$fontsize\">".$txt."</span>";
}
fontWrap("A Heading<br/>","24pt");
fontWrap("some body text<br/>");
fontWrap("smaller body text<br/>");
fontWrap("even smaller body text<br/>");
?>



Use Php class to control the HTML page font

<?php
class MyPageFont{
     var $header_face = "Tahoma";
     var $header_size = "7";
     var $body_face =   "Times New Roman";
     var $body_size =   "5";
     var $footer_face = "Letter Gothic";
     var $footer_size = "2";
     function set_header($face, $size)
     {
         $this->header_face = $face;
         $this->header_size = $size;
     }
     function set_body($face, $size)
     {
         $this->body_face = $face;
         $this->body_size = $size;
     }
     function set_footer($face, $size)
     {
         $this->footer_face = $face;
         $this->footer_size = $size;
     }
     function header_text($text)
     {
         echo "<font face="" . $this->header_face . "" size="" . $this->header_size . "">";
         echo $text;
         echo "</font>";
     }
     function footer_text($text)
     {
         echo "<font face="" . $this->footer_face . "" size="" . $this->footer_size . "">";
         echo $text;
         echo "</font>";
     }
     function body_text($text)
     {
         echo "<font face="" . $this->body_face . "" size="" . $this->body_size . "">";
         echo $text;
         echo "</font>";
     }
}
 
$style = new MyPageFont();
$style->header_text("<BR>this is a header");
$style->set_header("Tahoma", 6);
$style->header_text("<BR>this is a modified header");
$style->body_text("<BR>this is a body");
$style->footer_text("<BR>this is a footer");
?>
Источник — «http://nfex.ru/index.php/PHP/HTML»