php smarty变量的修饰
test.php代码: view plaincopy to clipboardprint?
assign("total",$total); //对模版中的变量赋值 $formatted_total = number_format($total); //格式化$total $smarty->assign("formatted_total",$formatted_total); //对模版中的变量赋值 $smarty->display('test1.htm'); //显示页面 ?>
assign("total",$total); //对模版中的变量赋值 $formatted_total = number_format($total); //格式化$total $smarty->assign("formatted_total",$formatted_total); //对模版中的变量赋值 $smarty->display('test1.htm'); //显示页面 ?> test1.html模板代码: view plaincopy to clipboardprint?
Total is {$total}
Formatted Total is {$formatted_total}
Total is {$total}
Formatted Total is {$formatted_total}
编译后的test.html.php代码: view plaincopy to clipboardprint?
Total is _tpl_vars['total']; ?>
Formatted Total is _tpl_vars['formatted_total']; ?>
Total is _tpl_vars['total']; ?>
Formatted Total is _tpl_vars['formatted_total']; ?>
test1.html模板可以改写成这样test2.html: view plaincopy to clipboardprint?
Total is {$total}
Formatted Total is {$total|number_format}
Total is {$total}
Formatted Total is {$total|number_format}
则相应的test.php代码改为: view plaincopy to clipboardprint?
assign("total",$total); //对模版中的变量赋值 $smarty->display('test2.htm'); //显示页面 ?>
assign("total",$total); //对模版中的变量赋值 $smarty->display('test2.htm'); //显示页面 ?> 浏览器显示: Total is 12345 Formatted Total is 12,345 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zhuzhao/archive/2009/03/19/4006030.aspx 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/zhuzhao/archive/2009/03/19/4006030.aspx
相关文档:
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 ......
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的具体安装步骤 (初 ......
function FormatShowTime($nTotalSec)
{
//echo "total sec:" . $nTotalSec . '<br>';
$strTime = "";
//day
if ($nTotalSec > 3600 * 24)
{
$nDay = (int)($nTotalSec / (3600 * 24));
//$nDay > 0 ? $nDay : 1;
$strTime = $nDay;
$strTime .= '天';
//echo "nDay: ......