折腾一个下午,把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
层叠式样表文件my.css
body {
background-color: #10F2E7;
}
table
n {
font-size: small;
font-family: arial, helvetica, sans-serif;
}
table {
overflow: scroll;
margin: 0.1px;
font-weight: lighter;
font-family: arial, helvetica, sans-serif;
}

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

SublimeText3漢化版
中文版,非常好用

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

SublimeText3 Linux新版
SublimeText3 Linux最新版

WebStorm Mac版
好用的JavaScript開發工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),