thinkphpÔõÑùÌí¼ÓÒ³Ãæ
thinkphpÊÇÒ»¿îºÜÊÇÊ¢ÐеÄphp¿ª·¢¿ò¼Ü£¬Ëü¾ßÓмòÆÓÒ×Óá¢ÎÞа¸ßЧ¡¢Çå¾²Îȹ̵ÈÓÅÊÆ£¬ÊÇ¿ª·¢webÓ¦ÓõÄÊ×Ñ¡¿ò¼ÜÖ®Ò»¡£ÄÇô£¬ÔõÑùÔÚthinkphpÖÐÌí¼ÓÒ³ÃæÄØ£¿½ÓÏÂÀ´£¬±¾ÎĽ«ÎªÄãÏêϸÏÈÈÝthinkphpÌí¼ÓÒ³ÃæµÄÒªÁì¡£
Ò»¡¢½¨Éè¿ØÖÆÆ÷
ÔÚ×îÏȽ¨ÉèÒ³Ãæ֮ǰ£¬ÎÒÃÇÐèÒªÏÈÏàʶʲôÊÇ¿ØÖÆÆ÷¡£¿ØÖÆÆ÷ÊÇÔÚMVC¼Ü¹¹ÖÐÈÏÕæ´¦ÀíÇëÇó²¢ÏìÓ¦µÄÒ»¸ö×é¼þ£¬ËüÊÇÕû¸öÓ¦ÓõĽ¹µã¡£Òò´Ë£¬Ìí¼ÓÒ³ÃæµÄµÚÒ»²½Êǽ¨Éè¿ØÖÆÆ÷¡£
½¨Éè¿ØÖÆÆ÷µÄÒªÁìºÜ¼òÆÓ£¬ÄãÖ»ÐèÒªÔÚThinkPHPµÄ¿ØÖÆÆ÷Ŀ¼Ï½¨ÉèÒ»¸öÒÔ¡°¿ØÖÆÆ÷ÃûController¡±ÎªÎļþÃûµÄphpÎļþ£¬ÀýÈçÎÒÃÇÒª½¨ÉèÒ»¸öÃûΪIndexµÄ¿ØÖÆÆ÷£¬¾ÍÐèÒªÔÚ¿ØÖÆÆ÷Ŀ¼Ï½¨ÉèÒ»¸öÃûΪIndexController.phpµÄÎļþ£¬ÆäÖеĴúÂëÈçÏ£º
namespace Home\Controller; use Think\Controller; class IndexController extends Controller { public function index() { $this->display(); } }
µÇ¼ºó¸´ÖÆ
¶þ¡¢½¨ÉèÄ£°å
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ÔÚ¿ØÖÆÆ÷ÖУ¬ÎÒÃÇÒª±àд¶ÔӦģ°åµÄ´úÂ룬ģ°å¾ÍÊÇÎÒÃÇÒ³ÃæµÄ½çÃæ¡£ÓÉÓÚThinkPHP½ÓÄÉÁËMVC·Ö²ãÉè¼Æ£¬ÒÔÊÇÎÒÃÇÐèÒªÔÚtemplateĿ¼Ï½¨Éè¶ÔÓ¦¿ØÖÆÆ÷µÄÄ£°åÎļþ£¬ÀýÈçÔÚtemplate/HomeĿ¼Ï½¨ÉèÒ»¸öÃûΪindex.htmlµÄÎļþ£¬ÔÚÎļþÖÐдÈë»ù±¾HTML´úÂ룬²¢ÇÒÌí¼ÓһЩPHP´úÂ룬ÀýÈ磺
nbsp;html> <meta> <title>ThinkPHP Ìí¼ÓÒ³Ãæ</title><h1>ThinkPHPÌí¼ÓÒ³Ãæ</h1> <?php echo 'Hello,ThinkPHP'; ?>
µÇ¼ºó¸´ÖÆ
Èý¡¢Â·ÓÉÉèÖÃ
ÔÚ½¨ÉèºÃ¿ØÖÆÆ÷ÓëÄ£°åºó£¬ÎÒÃÇ»¹ÐèÒªÉèÖ÷ÓÉ£¬ÒÔ±ãÈûá¼û¸ÃÒ³Ãæʱ׼ȷµÄ±»ÆÊÎöµ½¶ÔÓ¦µÄ¿ØÖÆÆ÷ºÍÄ£°å¡£ÉèÖ÷ÓɵÄÒªÁìÒ²ºÜ¼òÆÓ£¬Ö»ÐèÒªÔÚThinkPHPµÄ·ÓÉÉèÖÃÎļþÖÐÌí¼Ó¶ÔÓ¦µÄ·ÓɹæÔò¼´¿É¡£ÀýÈçÎÒÃÇÐèÒªÉèÖÃÒ»Ìõ·ÓɹæÔò£¬µ±Óû§»á¼û¡±http://www.example.com/index¡±Ê±£¬ËûÃǽ«±»ÆÊÎöµ½Index¿ØÖÆÆ÷ÖеÄindex()ÒªÁ죬·ÓÉÉèÖôúÂëÈçÏ£º
'URL_ROUTE_RULES' => array( 'index' => 'Home/Index/index', ),
µÇ¼ºó¸´ÖÆ
ÒÔÉϾÍÊÇÌí¼ÓÒ³ÃæµÄËùÓÐÀú³Ì£¬Äã¿ÉÒÔͨ¹ý»á¼û¡±http://www.example.com/index¡±Éó²éЧ¹û¡£²»¹ý£¬½¨ÒéÔÚ¿ª·¢Àú³ÌÖÐʹÓÃThinkPHPÌṩµÄÏÂÁîÐй¤¾ß¾ÙÐе÷ÊÔ£¬×èÖ¹ÔÚ¿ª·¢Àú³ÌÖб¬·¢ÒâÍâ¡£ÀýÈçÔÚÏÂÁîÐÐÖÐÊäÈ룺php think run index£¬ÔÚ»á¼û¡°http://127.0.0.1:8000/index¡±¼´¿ÉÉó²éЧ¹û¡£
×ÛÉÏ£¬Í¨¹ýÒÔÉϵÄÏÈÈÝ£¬ÄãÒѾÄܹ»ÕÆÎÕThinkPHPÔõÑùÌí¼ÓÒ³ÃæµÄÒªÁìÁË¡£Ï£Íû±¾ÎÄÄܹ»¶Ô¸÷ÈËÓÐËù×ÊÖú¡£
ÒÔÉϾÍÊÇthinkphpÔõÑùÌí¼ÓÒ³ÃæµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡