Smarty 模板 从php分配的变量 数组
index.php:
$smarty = new Smarty;
$smarty->assign('Contacts',
array('555-222-9876',
'zaphod@slartibartfast.com',
array('555-444-3333',
'555-111-1234')));
$smarty->display('index.tpl');
index.tpl:
{$Contacts[0]}
{$Contacts[1]}
{* you can print arrays of arrays as well *}
{$Contacts[2][0]}
{$Contacts[2][1]}
OUTPUT:
555-222-9876
zaphod@slartibartfast.com
555-444-3333
555-111-1234
相关文档:
在php中计算时间差有时候是件麻烦的事!不过只要你掌握了日期时间函数的用法那这些也就变的简单了:
一个简单的例子就是计算借书的天数,这需要php根据每天的日期进行计算,下面就来谈谈实现这种日期计算的几种方法:
(1) 如果有数据库就很容易了!若是MSSQL可以使用触发器!用专门计算日期差的函数datediff()便可 ......
php 使用命令行自变量
在命令行里输入程序参数来更改其运行方式是很常见的做法。你也可以对CLI程序这样做。PHP
CLI带有两个特殊的变量,专门用来达到这个目的:一个是$argv变量,它通过命令行把传递给PHP脚本的参数保存为单独的数组元素;另一个
是$argc变量,它用来保存$argv数组里元素的个数。
用 ......
1.基本类
//smarty_config.php
define('TEMPLATE_DIR','templates/');
define('COMPILE_DIR','templates_c/');
define('CONFIG_DIR','configs/');
define('CACHE_DIR','cache/');
?>
//View.class.php
//配置文件
require_once 'configs/smart_config.php';
//Smarty类
require('smarty/ ......
php的函数分为系统函数,用户函数
1,php函数不区分大小写
函数原型:
返回类型 函数名称(类型 参数)
2.1,系统函数中常用的数学函数
abs(eumber) 去绝对值
sin(float) 正弦计算sin(x)
cos(float) 余弦计算cos(x)
log(float) 自然对数计算
sqrt(float) 开平方根计算
log10(float) 10基底的对数
ex ......
index.php:
$smarty = new Smarty;
$smarty->assign('Contacts',
array('555-222-9876',
'zaphod@slartibartfast.com',
array('555-444-3333',
'555-111-1234')));
$smarty->display('index.tpl');
index.tpl:
{$Contacts[0]}
{$Contacts[1]}
{* you can print arrays of arrays ......