¥È¥Ã¥×   ¿·µ¬ °ìÍ÷ ñ¸ì¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS

PHP/Smarty ¤Î¥Ð¥Ã¥¯¥¢¥Ã¥×¥½¡¼¥¹(No.2)

[[[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}
¢¨Í½ÌóÊÑ¿ô[[{$smarty}>http://www.smarty.net/manual/ja/language.variables.smarty.php]]¤òÍøÍѤ·¤Þ¤¹¡£


*ÊÑ¿ô



**¥Æ¥ó¥×¥ì¡¼¥È¤ÇÊÑ¿ô¤òÄêµÁ¤·¤Æɽ¼¨
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]}¤È¤¤¤¦É÷¤Ë¤½¤Î¤Þ¤Þ¥Æ¥ó¥×¥ì¡¼¥È¤Ëµ­½Ò¤·¤Þ¤¹