在本章中我们将介绍一个实例,来进一步对类加深了解。
本章构建一个Page类,它代表了一个页面。其中有显示页面的title,样式,内容等函数。
此页面的效果如下:
PHP 14:类的实例
我们将把这个页面分成几块:
1)有图的那一块。
2)有导航按钮的那一块。
3)中间文字的一会
4)页底的这一块

具体看看代码吧:
?>
代码挺长的。此代码定义了一个Page类,此类有个方法为 class ProductPage extends Page
 {
      
private $line2buttons=array('PHP'=>'PHP.php','Apache HTTP Server'=>'Apache.php',
                                   
'MySql'=>'mysql.php','Zend Studio'=>'ZendStudio.php',
                                   
'UEStudio'=>'http://www.ultraedit.com');
          
public function DisplayPage()
     {
         
print "<html>\n<header>";
         
$this->DisplayTitle();
         
$this->DisplayStyles();
         
print "</header>\n<body>";
         
$this->DisplayHeader();
         
$this->DisplayMenus($this->buttons);
         
$this->DisplayMenus($this->line2buttons);
         
$this->DisplayContent();
         
$this->DisplayFooter();
         
print "</body>\n</html>";
     }
 }

 
$page=new ProductPage();
 
$page->content="本页面用来测试我们最先进的产品!这些产品正在测试中,很快将会粉墨登场!请耐心等待";
 
$page->DisplayPage();

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-02
  • 2021-07-25
  • 2021-06-04
  • 2021-11-28
  • 2021-10-27
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-12-29
相关资源
相似解决方案