PHP/Smarty ¤Î¥Ð¥Ã¥¯¥¢¥Ã¥×(No.1)
- ¥Ð¥Ã¥¯¥¢¥Ã¥×°ìÍ÷
- º¹Ê¬ ¤òɽ¼¨
- ¸½ºß¤È¤Îº¹Ê¬ ¤òɽ¼¨
- ¥½¡¼¥¹ ¤òɽ¼¨
- PHP/Smarty ¤Ø¹Ô¤¯¡£
- 1 (2010-09-06 (·î) 11:47:19)
- 2 (2010-09-06 (·î) 11:50:43)
- 3 (2010-09-06 (·î) 19:35:37)
- 4 (2010-09-09 (ÌÚ) 20:33:21)
[PHP]
¥³¥á¥ó¥È
¥³¥á¥ó¥È¤Ï¼¡¤Î¤è¤¦¤Ëµ½Ò¤·¤Þ¤¹¡£
foo.tpl
{* ¤³¤ì¤ÏSmarty¤Î¥³¥á¥ó¥È¤Ç¤¹ *}
Æþ¤ì»Ò¤Ë¤Ï¤Ç¤¤Þ¤»¤ó¡£
Äê¿ô
¥Æ¥ó¥×¥ì¡¼¥È¤ÇÄê¿ô¤òÄêµÁ¤·¤Æɽ¼¨
ÀßÄê¥Õ¥¡¥¤¥ë¤Ë¤è¤ëÊÑ¿ôÄêµÁ
foo.conf
fax = '111-222-3333'
foo.tpl
{config_load file='foo.conf'} {#fax#}
PHP¤ÇÄê¿ô¤òÄêµÁ¤·¤Æɽ¼¨
foo.php
define('FAX','111-222-3333');
foo.tpl
{$smarty.const.FAX}
ÊÑ¿ô
¥Æ¥ó¥×¥ì¡¼¥È¤ÇÊÑ¿ô¤òÄêµÁ¤·¤Æɽ¼¨
foo.tpl
{assign var=fax value='111-222-3333'} {$fax}
PHP¤ÇÊÑ¿ô¤òÄêµÁ¤·¤Æɽ¼¨
foo.php
$smarty = new Smarty(); $smarty->assign('fax', '111-222-3333');
foo.tpl
{$fax}
Ï¢ÁÛÇÛÎóÊÑ¿ô
PHP¤ÇÏ¢ÁÛÇÛÎóÊÑ¿ô¤òÄêµÁ¤·¤Æɽ¼¨
foo.php
$smarty = new Smarty(); $smarty->assign('foo', array('fax' => '111-222-3333', 'email' => 'zaphod@slartibartfast.example.com', 'phone' => array('home' => '111-222-3334', 'cell' => '111-222-3335') ) );
foo.tpl
{$foo.fax}
Ï¢ÁÛÇÛÎóÊÑ¿ô$foo['fax']¤òɽ¼¨ ¢¨Ï¢ÁÛÇÛÎó¤Ï¥Ô¥ê¥ª¥É¤ò»ÈÍѤ·¤Þ¤¹¡£ ¢¨Ä̾ï¤ÎÇÛÎó¤Ï{$foo[4]}¤È¤¤¤¦É÷¤Ë¤½¤Î¤Þ¤Þ¥Æ¥ó¥×¥ì¡¼¥È¤Ëµ½Ò¤·¤Þ¤¹