易截截图软件、单文件、免安装、纯绿色、仅160KB

php smarty基本使用

1.基本类
//smarty_config.php
<?php
define('TEMPLATE_DIR','templates/');
define('COMPILE_DIR','templates_c/');
define('CONFIG_DIR','configs/');
define('CACHE_DIR','cache/');
?>
//View.class.php
<?php
//配置文件
require_once 'configs/smart_config.php';
//Smarty类
require('smarty/Smarty.class.php');
class View extends Smarty {
function SmartyFactory() {
$this->Smarty();
//模板路径
$this->template_dir = TEMPLATE_DIR;
//编译后文件
$this->compile_dir = COMPILE_DIR;
//配置文件
$this->config_dir = CONFIG_DIR;
//缓存文件
$this->cache_dir = CACHE_DIR;
$this->debugging = true;
}
//重新封装display 个人习惯改成show
function show($name,$cacheId='') {
if($cacheId == '')
$this->display($name.'.htm');
else
$this->display($name.'.htm',$cacheId);
}
//重新封装assign 习惯用add
function add($name,$value) {
$this->assign($name,$value);
}
}
?>
基本目录如:
test
    |-configs
    |-templates
    |-templates_c
    |-cache
    |-smarty --smarty lib
2.基本使用
//index.php
<?php
require_once('View.php');
//数据查询 mysql_fetch_assoc() 返回数组
//数据库层封装
//如:$User = new User();
//$Users = $User->paging('参数');
$View = new View();
$View->add("users",$Users);
$View->show("index");
?>
//public.conf
[public]
public = public/
img = public/img/
css = public/css/
js = public/js/
//index.htm --在templates文件夹下 简短介绍下
<html>
<!-- 包含meta.htm文件-->
{include file="meta.htm"}
<!-- 利用smarty config文件 定义基本信息-->
{config_load file=public.conf section="public"}
<!-- 略 -->
<table>
 <tr>
  <!-- {#img#} img的基本路径 对于一般小网站的做法 如有是使用了二级域名的静态服务器没必要了-->
  <td><input type="image" src="{#img#}xxx.gif"/></td>
 </tr>


相关文档:

php对文件夹的操作 创建文件夹

//创建文件夹
function createdir($dir){
$edir = explode('/',$dir);
for($i=0;$i<count($edir);$i++)
{
$edirm = $edir[0];
for($ii=1;$ii<=$i;$ii++)
{
$edirm = $edirm.'/'.$edir[$ii];
}
if(file_exists($edirm) && is_dir($edirm))
{}
else
{
@mkdir ($edir ......

PHP $_GET


$_GET 变量用于收集来自 method="get" 的表单中的值。
$_GET 变量
$_GET 变量是一个数组,内容是由 HTTP GET 方法发送的变量名称和值。
$_GET 变量用于收集来自 method="get" 的表单中的值。从带有 GET 方法的表单发送的信息,对任何人都是可见的(会显示在浏览器的地址栏),并且对发送的信息量也有限制(最多 100 个 ......

你可以喜欢PHP,但是你不能撒谎!

最近我真是头大矣,我的博客里居然一夜间变成了php和asp的斗争场,甚至变成了windows和linux的斗争场。真是意想不到的。
我本来无意挑起windows和linux之间的争端,而且也非常不想去挑这种争端。
话说,其实我本身对linux操作系统是没有什么坏印象的,虽然自己的电脑上没有装过linux,但是在同学的电脑上用过,觉得它挺好 ......

apache and php common tips and problems

When I deploy php application on apache, some problem come out, and solved. Here's the tips and problems solved.
0.How could I deploy an apache server armed with php, mysql, perl, and phpMyAdmin on the fly?
You need a package bundled with all these tools,  xampp shall meet you needs, you can ......

java php DES 加密解密

import java.io.IOException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class DES {
private byte ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号