æºå¸¯ãµã¤ãã§Smartyã使ãå ´åã®æ³¨æç¹ Tweet 2008/2/12 ç«ææ¥ matsui Posted in PHP | 1 Comment » ãã±ã¼ã¿ã¤ãµã¤ãã«Smartyã使ããã¨ããããã¾ããããªããã¨ãã質åãããåãããã¨ãããã®ã§ã注æç¹ãã¾ã¨ãã¦ã¿ã¾ãã åé¡ã¨ãªãã®ã¯ãæåã³ã¼ãã«ãShift_JISãã使ã£ãå ´åã§ãã æè¿ã¯å¯¾å¿ç«¯æ«ãå¢ãããããUTF-8ã§ãã¼ã¸ãä½ãå ´åãå¤ãã§ãããéå»ã®è³ç£ãããäºææ§ã®åé¡ããã§Shift_JISã使ããã¨ãããã¾ãã ã¨ãããSmartyã§ã¯SJISã¯ä½¿ãã¾ããã ãªããªããSmartyã®æ¨æºã®ããªãã¿ã§ãã ã { ã (0x007b)ã ãã } ã (0x007d) ããSJISæååãå«ãã§ãã¾ã£ã¦ãããã¨ãããããã§ãã ï¼ã¤ã¾ãå¿ ãããã¨ã©ã¼ã«ã¯ãªããªããã¨ã«æ³¨æãå¿ è¦ã§ãï¼ ã¨ã©ã¼ãèµ·ãã£ãå ´åã«ã¯æ¬¡ã®
php+smartyã§åãã¦ããPCç¨ã®ãµã¤ããæºå¸¯ãµã¤ãã«å¤æãã¦ãã¾ãæ¹æ³ããç´¹ä»ã ããæ¹ã¯ç°¡åã ï¼ï¼ã¦ã¼ã¶ã¼ã¨ã¼ã¸ã§ã³ããIPãªã©ã§æºå¸¯ããã®ã¢ã¯ã»ã¹ãããã½ã³ã³ããã®ã¢ã¯ã»ã¹ããå¤å¥ããã ï¼ï¼æºå¸¯ããã®ã¢ã¯ã»ã¹ã ã£ãå ´åã¯smartyã®ãã³ãã¬ã¼ãé¢é£ãã£ã¬ã¯ããªãæºå¸¯ç¨ã®ãã³ãã¬ã¼ããå ¥ãããã£ã¬ã¯ããªã«åãæ¿ãã â»æºå¸¯ç¨ã®ãã³ãã¬ã¼ãã¯PCçã¨åãæåã³ã¼ãã«ãã¦ããã¦ãã ããã ï¼ï¼$smarty->displayãã¦ãã¨ãã§PCããã®ã¢ã¯ã»ã¹ã ã£ãå ´åã¯ãã®ã¾ã¾displayã§è¡¨ç¤ºãããã æºå¸¯ããã®ã¢ã¯ã»ã¹ã ã£ãå ´åã¯$smarty->fetchã§è¡¨ç¤ºçµæãå¤æ°ã«åå¾ãã mb_convert_encodingã使ã£ã¦æåã³ã¼ããSJISã«å¤æãã¦å¤æ°ã®å 容ãechoã§æ¸ãåºãã 以ä¸ã PCçã®ããã°ã©ã ãã»ã¨ãã©ããããã¨ãªãæºå¸¯ãµã¤ããããã§ã¤ããããã¾ãã
ãã®ï¼ã¤ã®ãã£ã«ã¿ã¼ã ãããããé©ç¨ãããã¿ã¤ãã³ã°ãéãããã§ãçµã¿åãã次第ã§ã¯ã¡ãã£ã¨ããå¹çåãå³ãã模æ§ã ã¢ãã¤ã«ãã¼ã¸ã®ä¸æ¬åè§å ã¢ãã¤ã«ãã¼ã¸ã§ã¯ãåè§ã«ãã使ç¨ãããã¨ãå¤ãã§ãããSmartyã®ãã³ãã¬ã¼ãã§ã¯å ¨è§ã§ä½æãã¦ããã¦ããã³ãã¬ã¼ãã®ç»é¢åºåæã«ãããä¸çºã§ãã£ã¡ãããï¼ã¨ããããæ¹ã <?php /* Smarty Include */ require_once('Smarty/Smarty.class.php'); /* create object */ $output_page = new MySmarty(); /* Smartyã§ãã³ãã¬ã¼ããç»é¢åºååã«ãå ¨è§->åè§åãããã */ $output_page->register_prefilter("convert_encoding_to_eucjp"); /* Smarty使ç¨ãã³ãã¬ã¼
æè¿ãæ°è¦ããã¸ã§ã¯ãæ¡ä»¶ã§æºå¸¯ãµã¤ãã®æ§ç¯ã«ã¤ãã¦ãããã調æ»ããã¦ãã¾ããæåããæºå¸¯ãµã¤ãã®æ§ç¯ã«ã¤ãã¦ã¯ã ããªããããããªç¹ã§æ¸å¿µã¯ãã¦ããã®ã§ãããèãéãã¦ã¿ãã¨ããã¯ããããã¨ãããããããç¹ãããªãå¤ãã§ãã ãããããä»åã®ããã¸ã§ã¯ãã«ããã¦ãããããªãµã¤ãã調æ»ãã¦ããã®ã§ããã ã¾ã ã¾ã PCãµã¤ãï¼XHTML+CSS+JavaScriptãªãµã¤ãï¼ã«æ¯ã¹ã¦ãæçãªæ å ±ãã¾ã¨ã¾ã£ã¦ããªããªãããã¨ããææ³ã§ãã ã¦ãã¦ã©ãããã¯æ¬å½ã«ç´ æ´ãããæ å ±ãé示ãã¦ãã ãã£ã¦ããã¨æãã¾ãããã ãããã¨ããã«æãå±ããããªæ å ±ã¯ã¾ã ã¾ã ä¸ã®ä¸ã«åºãã£ã¦ããªãããã§ãã®ã§ã åã調ã¹ãç¹ããå®è£ ãé²ããä¸ã§å¾ãTipsãªã©ãå ±æãã¦ããããã¨æãã¾ãã ããã§ãä»åã¯PHPã§æºå¸¯ãµã¤ããå®è£ ããä¸ã§ã®Tipsãè¨ãã¦ããããã¨æãã¾ãã 対象æ©ç¨®ã3Gã«çµã æºå¸¯ãµã¤ãã®æ§
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}