ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

½éÉÜÒ»ÏÂsmartyµÄÓô¦£¬ÅäÖ÷½·¨
2014-11-24 01:45:52 ¡¾´ó ÖРС¡¿ ä¯ÀÀ:247´Î
Tags£º½éÉÜ smarty Óô¦ ÅäÖà ·½·¨

smarty£º½â¾öphpºÍhtml´úÂë·ÖÀë¡£



1.1 smarty°²×°


1>http://smarty.php.net ÏÂÔØ


2>½âѹºó libsÎļþ¼Ð£¬smartyºËÐÄÎļþ¼Ð¡£¿½±´µ½ÄãµÄ¹¤×÷Ŀ¼¡£libs/Smarty.class.php


3>ºÍlibsƽ¼¶µÄĿ¼Ï£¬´´½¨Îļþ¼Ð


templates Íøҳģ°å£º*.html ***********


templates_c ±àÒëºóµÄ´úÂë


configs ÅäÖÃÎļþ


cache »º´æËùÓеÄÄ£°å



1.2 smartyµÄÅäÖÃ


1¡¢°¸Àý


smarty_02.php


require_once(¡°libs/Smarty.class.php¡±); //ÒýÈë


$smarty= new Smarty(); //ʵÀý»¯Ò»¸ö¶ÔÏó¡£



$smarty->assign(¡°awt¡±,$a); //Ϊģ°åµ±ÖеıäÁ¿¸³Öµ¡£Í¬Ê±¿ÉΪÊý×鸳ֵ


$smarty->display(¡°smarty_02.htm¡±); //Ä£°åÒ³µ÷ÓÃ



smarty_02.htm


¿ÉÒÔµ÷ÓÃÊý×é¡££¿£¿£¿£¿£¿£¿£¿£¿£¿



2¡¢smartyÅäÖá£


/* ¸Ä±äsmartyµÄÅäÖÃĿ¼½á¹¹¡£


$smarty->templates = ¡°a/templates¡±;


$smarty->templates_c = ¡°a/templates_c¡±;


$smarty->configs = ¡°a/configs¡±;


$smarty->cache = ¡°a/cache¡±;


*/



3¡¢Ä£°åÒ³µ±ÖУ¬Èç¹ûдÑùʽ£¬ÒòΪÓÐ{}£¬ÒýÆðÓïÒå»ìÂÒ£¬³ö´í¡£


1¡·Ð½¨cssÎļþ¡£°ÑÑùʽдÔÚcssÎļþÖУ¬±ÜÃâÁËÓïÒå»ìÂÒÁË¡£


ÔÚÄ£°åÖÐÈç¹ûµ÷ÓÃcssÑùʽ£¬ÊÇÒÔphpÎļþΪÖ÷¡£


2¡·¿ÉÒԸıäÄ£°åÖеĶ¨½ç·û¡°{}¡±==¡·¡°¡±


$smarty->left_delimiter = ¡°

$smarty->right_delimiter = ¡°}¨C>¡±;



smartyÓï·¨


1¡¢¿ØÖƽṹ




Ìõ¼þ1³ÉÁ¢µÄ´úÂë



Ìõ¼þ1³ÉÁ¢µÄ´úÂë



Ìõ¼þ3³ÉÁ¢µÄ´úÂë


¡­¡­¡­.



ÒÔÉÏÌõ¼þ¶¼²»³ÉÁ¢Ö´ÐÐelse



2¡¢Ñ­»·½á¹¹


while for do..while foreach


1¡·foreach


¸ñʽ£º


{foreach from=Êý×éÃû³Æ item=Êý×鵱ǰԪËØÃû}


Ñ­»·Ìå¡£


{/foreach}


Àý£º//¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª-²âÊÔforeach¡ª¡ª¡ª¡ª¡ª¡ª¡ª¨C


2¡·section


¸ñʽ£º


{section name=¡±µ±Ç°ÔªËØ¡± loop=¡±Êý×éÃû³Æ¡±}


Ñ­»·Ìå


{/section}


Àý£º//¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª-²âÊÔsection¡ª¡ª¡ª¡ª¡ª¡ª¡ª¨C


¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
ÉÏһƪ£ºÊµÏÖË«ÏòÁ´±íɾ³ýÒ»¸ö½ÚµãP£¬ÔÚ½Ú.. ÏÂһƪ£ºOracleÊý¾Ý¿âµÄÎïÀíÎļþÓÐÄļ¸ÖÖ..

×îÐÂÎÄÕÂ

ÈÈÃÅÎÄÕÂ

Hot ÎÄÕÂ

Python

C ÓïÑÔ

C++»ù´¡

´óÊý¾Ý»ù´¡

linux±à³Ì»ù´¡

C/C++ÃæÊÔÌâÄ¿