検索
ホームページphp教程php手册Smarty と html_QuikForm の間の共同プログラミング

  折腾一个下午,把smarty和html_QuikForm联结到一起了源码:

test.php

      require_once "HTML/QuickForm.php";
      require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
      require_once 'link/myload.php';

      $form = new HTML_QuickForm('frmTest', 'get');
      $form->addElement('header', 'hdrTesting', 'Smarty&HTML/QuickForm联合编程实验');
      $form->addElement('text', 'txtFirstName', '贵姓?');
      $form->addElement('text', 'txtLastName', '尊名?');
      $form->addElement('text', 'txtAge', '年龄?');
      $form->addElement('text', 'txtTelephone', '电话?');
      $form->addElement('reset', 'btnClear', '复位');
      $form->addElement('submit', 'btnSubmit', '提交');
      if ($form->validate()) {
          # If the form validates then freeze the data
          $form->freeze();
      }

      // Create the template object
      $tpl =$smarty=& new Smarty_my;
    
            $tpl->compile_check = true;
      // Create the renderer object   
      $renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl);

      // build the HTML for the form
      $form->accept($renderer);

      // assign array with form data
      $tpl->assign('form_data', $renderer->toArray());

      // parse and display the template
      $tpl->display('my.tpl');

  ?>

mylink.php

// load Smarty library
define('myclude',/usr/share/php/smarty');
require(myinclude.'/libs/Smarty.class.php');

//setup.php是一个很好的加载应用程序的类库文件(就是扩展类)
//例如你可以在index文件里包含它

class Smarty_my extends Smarty {

   function Smarty_my() {
  
           // Class Constructor. These automatically get set with each new instance.
//类构造函数.创建实例的时候自动配置
        $this->Smarty();

        $this->template_dir = '/var/www/apache2-default/smarty/xsgl/templates/';
        $this->compile_dir = '/var/www/apache2-default/smarty/xsgl/templates_c/';
        $this->config_dir = '/var/www/apache2-default/smarty/xsgl/configs/';
        $this->cache_dir = '/var/www/apache2-default/smarty/xsgl/cache/';
       
        $this->caching = true;
        $this->assign('app_name','xsgl');
   }

}

模板文件my.tpl








gt;



< ;!-- フィールドを表示 -->
















©2005

层叠式样表文件my.css

body { background-color: #10F2E7;}

table

n {
font-size: small;
font-family: arial、helvetica、sans-serif;

}

table {
オーバーフロー: スクロール;
マージン: 0.1px ;
font-weight: 軽い;
font-family: arial、helvetica、sans-serif;
}




gt;
& lt;/th>

gt;


声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

強力な PHP 統合開発環境

MantisBT

MantisBT

Mantis は、製品の欠陥追跡を支援するために設計された、導入が簡単な Web ベースの欠陥追跡ツールです。 PHP、MySQL、Web サーバーが必要です。デモおよびホスティング サービスをチェックしてください。

PhpStorm Mac バージョン

PhpStorm Mac バージョン

最新(2018.2.1)のプロフェッショナル向けPHP統合開発ツール