page.inc.php
1 <?php 2 class page{ 3 public $content; 4 public $title="tla consulting pty ltd"; 5 public $keywords="tla consulting,three latter abbreviation,some of my best friends are search engines"; 6 public $buttons=array("home"=>"home.php", 7 "contact"=>"contact.php", 8 "services"=>"services.php", 9 "site map"=>"map.php" 10 ); 11 public function __set($name,$value){ 12 $this->name=$value; 13 } 14 public function display(){ 15 echo "<html>\n<head>\n"; 16 $this->displaytitle(); 17 $this->displaykeywords(); 18 $this->displaystyles(); 19 echo "</head>\n<body>\n"; 20 $this->displayheader(); 21 $this->displaymenu($this->buttons); 22 echo $this->content; 23 $this->displayfooter(); 24 echo "</body>\n</html>\n"; 25 } 26 public function displaytitle(){ 27 echo "<title>".$this->title."</title>"; 28 } 29 public function displaykeywords(){ 30 echo "<meta name=\"keywords\" content=\"".$this->keywords."\"/>"; 31 } 32 public function displaystyles(){ 33 ?> 34 <style> 35 h1{ 36 color:white;font-size:24pt;text-align:center; 37 font-family:arial,sans-serif 38 } 39 .menu{ 40 color:white;font-size:12pt;text-align:center; 41 font-family:arial,sans-serif;font-weight:bold 42 } 43 td{ 44 background:black 45 } 46 p{ 47 color:black;font-size:12pt;text-align:justify; 48 font-family:arial,sans-serif 49 } 50 p.foot{ 51 color:white;font-size:9pt;text-align:center; 52 font-family:arial,sans-serif;font-weight:bold 53 } 54 a:link,a:visited,a:activep{ 55 color:white 56 } 57 </style> 58 <?php 59 } 60 public function displayheader(){ 61 ?> 62 <table width=100% cellpadding="12" cellspacing="0" border="0"> 63 <tr bgcolor="black"> 64 <td align="left"><img src="logo.jpg"/></td> 65 <td> 66 <h1>huahua‘s page</h1> 67 </td> 68 <td align="right"><img src="logo.jpg"/></td> 69 </tr> 70 </table> 71 <?php 72 } 73 public function displaymenu($buttons){ 74 echo "<table width=\"200\" bgcolor=\"white\" cellpadding=\"4\"cellspacing=\"4\">\n"; 75 echo "<tr>\n"; 76 $width=200/count($buttons); 77 while (list($name,$url)=each($buttons)) { 78 //注意: !$this->IsURLCurrentPage 79 $this->displaybutton($width,$name,$url,!$this->IsURLCurrentPage($url)); 80 } 81 echo "</tr>\n"; 82 echo "</table>\n"; 83 } 84 public function IsURLCurrentPage($url){ 85 //判断这个url是否指向当前页面. 86 //如果指向当前页面返回true 87 if (strpos($_SERVER[‘PHP_SELF‘],$url)==false) { 88 return false; 89 }else{ 90 return true; 91 } 92 } 93 public function displaybutton($width,$name,$url,$active=true){ 94 if ($active) { 95 echo "<td width=\"".$width."%\"> 96 <a href=\"".$url."\"> 97 <img src=\"s-logo.jpg\" alt=\"".$name."\" border=\"0\"/></a> 98 <a href=\"".$url."\"><span class=\"menu\">".$name."</span></a> 99 </td>"; 100 }else{ 101 echo "<td width=\"".$width."%\"> 102 <img src=\"side-logo.jpg\"><span class=\"menu\">".$name."</span></td>"; 103 } 104 } 105 public function displayfooter(){ 106 ?> 107 <table width="100%" bgcolor="black" cellpadding="12" border="0"> 108 <tr> 109 <td> 110 <p class="foot">©tla consulting pty ltd.</p> 111 <p class="foot">please see our<a href="">legal infotmation page</a></p> 112 </td> 113 </tr> 114 </table> 115 <?php 116 } 117 } 118 ?>
home.php
1 <?php 2 require(‘page.inc.php‘); 3 $homepage=new page(); 4 $homepage->title="huahua girl is best!"; 5 $homepage->content="huahua girl have good good study,day day up!!!"; 6 $homepage->display(); 7 ?>
service.php
1 <?php 2 require(‘page.inc.php‘); 3 class servicespage extends page{ 4 private $roe2buttons=array( 5 "reengineering"=>"reengineering.php", 6 "standards compliance"=>"standards.php", 7 "buzzword conliance"=>"buzzword.php", 8 "mission statements"=>"mission.php" 9 ); 10 //继承了page类 新增了及格菜单 11 public function display(){ 12 echo "<html>\n<head>\n"; 13 $this->displaytitle(); 14 $this->displaykeywords(); 15 $this->displaystyles(); 16 echo "</head>\n<body>\n"; 17 $this->displayheader(); 18 $this->displaymenu($this->buttons); 19 $this->displaymenu($this->roe2buttons); 20 echo $this->content; 21 $this->displayfooter(); 22 echo "</body>\n</html>\n"; 23 } 24 } 25 $service=new servicespage(); 26 $service->content="<p>this is service page</p>"; 27 $service->display(); 28 ?>
界面显示:
时间: 2024-11-14 00:10:42