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
Ïà¹ØÎĵµ£º
Ò»¡¢¹æ·¶Ç°ÑÔÆª
±ê×¼»¯²»ÊÇÌØÊâµÄ¸öÈË·ç¸ñ£¬ËüÈóÌÐòÔ±¿ÉÒÔÁ˽âÈκδúÂ룬ŪÇå³ÌÐòµÄ×´¿ö£»ÐÂÈË¿É
ÒԺܿìµÄÊÊÓ¦»·¾³£»·ÀֹнӴ¥phpµÄÈËÒ»´Î´ÎµÄ·¸Í¬ÑùµÄ´íÎó£»ÔÚÒ»ÖµĿª·¢»·¾³Ï£¬
¿ÉÒÔ¼õÉÙÈËÃÇ·¸´íµÄ»ú»á¡£±¾¹æ·¶µÄ±ê×¼ÔÚ¾ø¶Ô¶àÊýÓ¦ÓÃÉÏΪ·ÂÕÕjava¼¼ÊõÌåϵ£¬ÒòΪ
java¼¼ÊõÌåϵÒÔÆäÖÚ¶à³É¹¦µÄ°¸Àý³ÉΪ´ó²¿·Ö¼ÆËã»úÓ¦Ó ......
1£¬Notice: Undefined variable½â¾ö°ì·¨
PHPĬÈÏÅäÖûᱨÕâ¸ö´íÎó£¬ÎÒµÄPHP°æ±¾ÊÇ5.2.9-1,´æÔÚÕâ¸öÎÊÌ⣺
Notice: Undefined variable
Õâ¾ÍÊǽ«¾¯¸æÔÚÒ³ÃæÉÏ´òÓ¡³öÀ´£¬ËäÈ»ÕâÊÇÓÐÀûÓÚ±©Â¶ÎÊÌ⣬µ«ÊµÏÖʹÓÃÖÐ»á´æÔںܶàÎÊÌâ¡£
ÐèÒªÉèÖÃÏÔʾ´íÎó¼¶±ð£¬À´½â¾öÎÊÌâ¡£
ÍøÂçÉϵÄͨÓýâ¾ö°ì·¨ÊÇÐÞ¸Äphp.iniµÄÅäÖãº
½â¾ö·½·¨ ......
¡¡»¥ÁªÍøµÄ½ñÌ죬AJAXÒѾ²»ÊÇʲôİÉúµÄ´Ê»ãÁË¡£ËµÆðAJAX£¬¿ÉÄÜ»áÁ¢¼´ÏëÆðÒòRSS¶øÐËÆðµÄXML¡£XMLµÄ½âÎö£¬¿ÖÅÂÒѾ²»ÊÇʲôÄÑÌâ
ÁË£¬ÌرðÊÇPHP5£¬´óÁ¿µÄXML½âÎöÆ÷µÄÓ¿ÏÖ£¬Èç×îÇáÁ¿¼¶µÄSimpleXML¡£²»¹ý¶ÔÓÚAJAXÀ´Ëµ£¬XMLµÄ½âÎö¸üÇãÏòÓÚǰ̨Javascript
µÄÖ§³Ö¶È¡£ÎÒÏëËùÓнâÎö¹ýXMLµÄÈË£¬¶¼»áÒòÊ÷ºÍ½Úµã¶øÍ·´ó¡£²»¿É·ñÈÏ£¬X ......
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 ......
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: ......