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]}<br>
{$Contacts[1]}<br>
{* you can print arrays of arrays as well *}
{$Contacts[2][0]}<br>
{$Contacts[2][1]}<br>
OUTPUT:
555-222-9876<br>
zaphod@slartibartfast.com<br>
555-444-3333<br>
555-111-1234<br>
相关文档:
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/ ......
1,Notice: Undefined variable解决办法
PHP默认配置会报这个错误,我的PHP版本是5.2.9-1,存在这个问题:
Notice: Undefined variable
这就是将警告在页面上打印出来,虽然这是有利于暴露问题,但实现使用中会存在很多问题。
需要设置显示错误级别,来解决问题。
网络上的通用解决办法是修改php.ini的配置:
解决方法 ......
说明:
1、本文档是为初学PHP的朋友而制作的。
2、看了本文档学会PHP的朋友,请反馈你对本文档的意见或建议(发邮件到kuaiyigang@163.com或在QQ群4798654中提出),以帮助更多的初学者。
1、php语言的概述及开发环境的配置(1天)
a、php发展及应用介绍(了解)
b、php及相关软件在类linux和windows的具体安装步骤 (初 ......
php的函数分为系统函数,用户函数
1,php函数不区分大小写
函数原型:
返回类型 函数名称(类型 参数)
2.1,系统函数中常用的数学函数
abs(eumber) 去绝对值
sin(float) 正弦计算sin(x)
cos(float) 余弦计算cos(x)
log(float) 自然对数计算
sqrt(float) 开平方根计算
log10(float) 10基底的对数
ex ......