thinkphpÔõôÅþÁ¬html
thinkphpÊÇÒ»¸ö»ùÓÚmvcģʽµÄ¿ªÔ´php¿ò¼Ü£¬Ëü½ÓÄÉÁËÃæÏò¹¤¾ßµÄ±à³ÌÍ·ÄÔ£¬Ê¹µÃ¿ª·¢Ö°Ô±Äܹ»¿ìËÙ¸ßЧµØ¿ª·¢³öÇå¾²¿É¿¿µÄwebÓ¦ÓóÌÐò¡£ÔÚthinkphpÖУ¬ÅþÁ¬htmlÎļþ¿ÉÒÔͨ¹ýÄ£°åÒýÇæÀ´ÊµÏÖ¡£
Ä£°åÒýÇæÊÇÒ»ÖÖ½«ÄÚÈÝÓëÑùʽÊèÉ¢µÄÊÖÒÕ£¬Ëü½«HTML´úÂëºÍPHP´úÂëÍÑÀ룬ʹµÃÇ°¶Ë¿ª·¢Ö°Ô±ºÍºó¶Ë¿ª·¢Ö°Ô±¿ÉÒÔ¸÷×ÔרעÓÚ×Ô¼ºµÄÊÂÇ飬Ìá¸ßÁË¿ª·¢Ð§ÂʺʹúÂë¿Éά»¤ÐÔ¡£
ÅþÁ¬htmlÎļþµÄÏêϸ°ì·¨ÈçÏ£º
½¨ÉèÒ»¸öHTMLÎļþ£¬±àдҳÃæ½á¹¹ºÍÑùʽ£¬½«ÆäÉúÑÄÔÚÏîÄ¿µÄpublicĿ¼Ï£¬ÀýÈçÏîĿ·¾¶Îª¡°/var/www/html/demo¡±£¬Ôò¿ÉÒÔ½«HTMLÎļþÉúÑÄÔÚ¡°/var/www/html/demo/public/index.html¡±¡£
ÔÚThinkPHPÏîÄ¿Öн¨ÉèÒ»¸ö¿ØÖÆÆ÷£¬ÀýÈçÃüÃûΪIndexController¡£
ÔÚIndexControllerÖн¨ÉèÒ»¸öÒªÁ죬ÀýÈçÃüÃûΪindex£¬ÓÃÓÚäÖȾHTMLÄ£°åÎļþ¡£
ÔÚindexÒªÁìÖÐŲÓÿò¼ÜÄÚÖõÄÄ£°åÒýÇ棬ÔÚÄ£°åÖÐʹÓÃinclude±êÇ©ÒýÈëHTMLÎļþ¡£
ÏÂÃæÊÇÒ»¸öʾÀý´úÂ룺
<?php namespace appindexcontroller; use thinkController; class Index extends Controller { public function index() { return $this->fetch('public/index.html'); } }
µÇ¼ºó¸´ÖÆ
ÔÚÉÏÊöʾÀý´úÂëÖУ¬ÎÒÃǽ¨ÉèÁËÒ»¸öIndex¿ØÖÆÆ÷£¬ÆäÖаüÀ¨Ò»¸öindexÒªÁ죬Õâ¸öÒªÁìͨ¹ý¿ò¼ÜÄÚÖõÄÄ£°åÒýÇæÀ´¼ÓÔØpublicÎļþ¼ÐϵÄindex.htmlÎļþ¡£ÆäÖÐfetchÒªÁì¿ÉÒÔ¶ÁÈ¡Ö¸¶¨Â·¾¶ÏµÄÄ£°åÎļþ£¬²¢·µ»Ø¾ÓÉ´¦Öóͷ£ºóµÄHTML´úÂ룬¼´ÊµÏÖÁËÔÚHTMLÎļþÖÐǶÈëPHP´úÂë¡£
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ÐèҪעÖصÄÊÇ£¬ÓÉÓÚHTMLÎļþºÍPHP´úÂë»®·ÖÉúÑÄÔÚ²î±ðµÄĿ¼Ï£¬ÒÔÊÇÔÚHTMLÎļþÖÐÒýÈëCSSºÍJavaScriptÎļþʱ£¬Â·¾¶ÐèҪƾ֤ÏêϸµÄÎļþλÖÃÀ´ÉèÖá£ÈôÊÇHTMLÎļþÖÐʹÓÃÁËÏà¶Ô·¾¶£¬»¹ÐèҪ˼Á¿µ½Ä£°åÒýÇæ¶ÔHTMLÎļþµÄ·¾¶×öÁËÒ»¶¨µÄ´¦Öóͷ££¬¿ÉÄÜ»áÓ°Ïìµ½×ÊÔ´ÎļþµÄ·¾¶¡£
ThinkPHP×÷Ϊһ¿îÓÅÒìµÄPHP¿ò¼Ü£¬ÌṩÁËÇ¿Ê¢µÄÄ£°åÒýÇæºÍ±ã½ÝµÄÎļþ²Ù×÷¹¦Ð§£¬Ê¹µÃÅþÁ¬HTMLÎļþ±äµÃÇáËÉ×ÔÈô¡£Ê¹ÓÃThinkPHP¿ª·¢WebÓ¦ÓóÌÐò£¬¿ª·¢Ö°Ô±¿ÉÒÔרעÓÚÓªÒµÂß¼µÄʵÏÖ£¬Í¬Ê±°ü¹Ü´úÂëµÄ¿Éά»¤ÐԺͿÉÀ©Õ¹ÐÔ¡£
ÒÔÉϾÍÊÇthinkphpÔõôÅþÁ¬htmlµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡