配置文件局部变量和全局变量

来源:互联网 发布:合影软件 编辑:程序博客网 时间:2024/06/02 04:31

————————————————————————————————————配置文件 ——————————————————————————————————

# 全局变量
[]局部变量
bgColor = #00cccc
display=true

[mycolor]
bgColor = #cccc00

 

[yourcolor]
bgcolor = #123456
———————————————————————————————————————————————————————————————————————————

<{config_load file="a.conf" section="mycolor"}>\\调用配置文件

——————————————————————————————————————————————————————————————————————————----

<?php
include("Smarty/libs/Smarty.class.php");
$link = mysql_connect('localhost','root','') or die("连接数据库失败");
mysql_select_db('XSXX');
$q = "select * from stu where id like '".trim($_POST["text"])."'";
$result = mysql_query($q,$link);
$row = mysql_fetch_row($result);
$s = new Smarty();

$s->reInitSmarty("Smarty/demo/templates","Smarty/demo/templates_c");//通过自定义方法实现编译目录及界定符的修改
$s->assign("text",$row);
$s->assign("dq",$_POST["dqfs"]);
$s->display("if.tpl");

\\调用数据库内容的php文件

——————————————————————————————————————————————————————————————————————————

 

<body>
<form action="if_smarty.php" method="post">
请输入学号进行查询:
<input type="text" name="text" /><br />
请选择显示方式:
<input type="radio" value="left" name="dqfs" />left
<input type="radio" value="center" name="dqfs" />center
<input type="radio" value="right" name="dqfs" />right
<br />
<input type="submit" value="提交" />
</form>
</body>

 

\\html文件跳转到php文件

原创粉丝点击