怎么用php设置界面
发布网友
发布时间:2022-07-29 19:35
我来回答
共2个回答
热心网友
时间:2023-11-29 09:00
php脚本分离和好看的界面没啥关系吧?
界面好看主要是美工,css,js的问题
分离目前流行的大概就是两个模板,具体模板用法请查看手册。简单例子:
1:smarty模板(去下载个smarty的包,里边有demo)
<?php
require '../libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->compile_check = true;
$smarty->debugging = true;
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill");
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"),
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
$smarty->assign("option_values", array("NY","NE","KS","IA","OK","TX"));
$smarty->assign("option_output", array("New York","Nebraska","Kansas","Iowa","Oklahoma","Texas"));
$smarty->assign("option_selected", "NE");
$smarty->display('index.tpl');
?>
2:template对象
用法:下载template对象模板
test.php
<?php
require_once("../inc/template.inc.php");
$tmplt = new Template();
$tmplt -> set_file("hd", test.htm");
$url_block='test';
$tmplt -> set_var('url_block',$url_block);
$tmplt -> parse("ot","hd");
$tmplt -> p("ot");
?>
test.htm
<html>
<div >{url_block}</div>
</html>
热心网友
时间:2023-11-29 09:01
可以用框架!
采用MVC模式!