帝國CMS顯示“Hello,world”程序編寫例子_帝國Cms教程

      編輯Tag賺U幣
      教程Tag:暫無Tag,歡迎添加,賺取U幣!
      顯示“Hello,world”程序編寫例子
      程序代碼編寫
      存放目錄格式:
      插件程序存放目錄用:/e/extend/helloworld/
      插件程序模板存放目錄用:/e/extend/helloworld/template/
      所需程序文件:
      /e/extend/helloworld/index.php主程序文件
      /e/extend/helloworld/template/index.temp.php主程序模板文件

      程序目錄模板目錄
      主程序文件內容(/e/extend/helloworld/index.php):
      <?php
      require('../../class/connect.php'); //引入數據庫配置文件和公共函數文件
      require('../../class/db_sql.php'); //引入數據庫操作文件
      $link=db_connect(); //連接MYSQL
      $empire=new mysqlquery(); //聲明數據庫操作類
      $editor=1; //聲明目錄層次

      $context='Hello, World!'; //定義顯示內容
      require('template/index.temp.php'); //導入模板文件

      db_close(); //關閉MYSQL鏈接
      $empire=null; //注消操作類變量
      ?>


      主程序模板文件內容(/e/extend/helloworld/template/index.temp.php):
      <?php
      if(!defined('InEmpireCMS'))
      {
             exit();
      }
      ?>

      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
      <title>顯示<?=$context?>例子</title>
      </head>
      <body>
      <br>
      <br>
      <br>
      <table width="500" border="0" align="center" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
       <tr>
         <td height="25"><strong>顯示內容為如下:</strong></td>
       </tr>
       <tr>
         <td height="60" bgcolor="#FFFFFF"> <div align="center"><strong><font color="#FF0000" size="5"><?=$context?></font></strong></div></td>
       </tr>
      </table>
      </body>
      </html>
      說明:模板可用Dreamweaver可視化制作。其中藍色部分代碼為不允許直接訪問模板文件的作用。
      訪問Hello World插件文件主程序:/e/extend/helloworld/index.php


      查看更多 帝國cms教程  帝國cms模板

      來源:未知//所屬分類:帝國Cms教程/更新時間:2012-10-13
      相關帝國Cms教程