thinkphpÖг£ÓõÄÒýÈëÉèÖÃÓÐÄÄЩ
Ò»¡¢ÒýÈëÎļþ
ΪÁËʹÓÃThinkPHP¿ò¼ÜÌṩµÄ¹¦Ð§£¬ÎÒÃÇÐèÒª½«¿ò¼ÜÄÚµÄһЩÀà¿âÒýÈëµ½ÎÒÃǵijÌÐòÖС£ÔÚThinkPHPÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏÂÁ½ÖÖ·½·¨¾ÙÐÐÎļþÒýÈë¡£
ÒýÈë¿ò¼ÜĬÈÏÎļþ
¿ò¼ÜĬÈÏÎļþ±»´æ´¢ÔÚframeworkĿ¼Ï£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÒÔÏ·½·¨¾ÙÐÐÒýÈ룺
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
require_once 'framework/thinkphp.php';
µÇ¼ºó¸´ÖÆ
ÕâÑù¾Í»á½«¿ò¼ÜĬÈÏÎļþÒýÈ뵽Ŀ½ñÎļþÖУ¬Àû±ãÎÒÃÇʹÓÿò¼ÜµÄ¹¦Ð§¡£
ÒýÈëÖ¸¶¨µÄÎļþ
ÓÐʱ¼äÎÒÃÇÖ»ÐèÒªÒýÈëÌض¨µÄÎļþ£¬¶ø²»±Ø°áÈëÕû¸ö¿ò¼Üµ½ÎÒÃǵijÌÐòÖС£ÔÚThinkPHPÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏ·½·¨¾ÙÐÐÒýÈ룺
require_once 'path/filename.php';
µÇ¼ºó¸´ÖÆ
ÕâÀïµÄpathÊÇÖ¸ÎÒÃÇÐèÒªÒýÈëµÄÎļþËùÔڵķ¾¶£¬filenameÔòÊÇÎļþÃû£¬ÐèÒª°üÀ¨ÎļþÀ©Õ¹Ãû¡£
¶þ¡¢ÉèÖ÷ÓÉ
ÔÚThinkPHPÖУ¬ÎÒÃÇ¿ÉÒÔͨ¹ý½ç˵·ÓɹæÔò£¬½«ÇëÇó·¢Ë͵½Ö¸¶¨µÄ¿ØÖÆÆ÷ºÍ²Ù×÷ÖУ¬ÒÔµÖ´ï×Ô½ç˵URLµÄÄ¿µÄ¡£ÔÚThinkPHPÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏ´úÂë¾ÙÐзÓÉÉèÖãº
'URL_ROUTER_ON' => true, // ¿ªÆô·ÓÉ 'URL_ROUTE_RULES'=>array( //½ç˵·ÓɹæÔò 'user/:id'=>'user/show', ),
µÇ¼ºó¸´ÖÆ
ÕâÀïµÄ’user/:id’=>’user/show’ÌåÏÖ½«ËùÓÐ/user/idµÄÇëÇ󶼷¢Ë͵½user¿ØÖÆÆ÷µÄshow²Ù×÷ÖС£Õë¶Ô·ÓÉÉèÖã¬ÎÒÃÇ¿ÉÒÔ½èÖúÕýÔò±í´ïʽµÈÆäËû·½·¨£¬Ê¹Æä¸ü¾ßµ¯ÐÔµØÉ趨·ÓɹæÔò¡£
Èý¡¢ÉèÖÃÊý¾Ý¿â
ΪÁ˾ÙÐÐÏà¹Ø²Ù×÷£¬ÎÒÃÇÐèÒªÅþÁ¬Êý¾Ý¿âÀ´¿ª·¢ThinkPHP³ÌÐò¡£ÔÚThinkPHPÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÒÔÏ´úÂë¾ÙÐÐÊý¾Ý¿âÉèÖãº
'DB_TYPE'=> 'mysql', // Êý¾Ý¿âÀàÐÍ 'DB_HOST'=> 'localhost', // ЧÀÍÆ÷µØµã 'DB_NAME'=>'test', // Êý¾Ý¿âÃû 'DB_USER'=>'root', // Óû§Ãû 'DB_PWD'=>'123456', // ÃÜÂë 'DB_PORT'=>'3306', // ¶Ë¿Ú 'DB_PREFIX'=>'think_', // Êý¾Ý¿â±íǰ׺
µÇ¼ºó¸´ÖÆ
ÕâÀïµÄDB_TYPEÌåÏÖÊý¾Ý¿âÀàÐÍ£¬DB_HOSTÌåÏÖЧÀÍÆ÷µØµã£¬DB_NAMEÌåÏÖÊý¾Ý¿âÃû£¬DB_USERÌåÏÖÊý¾Ý¿âÓû§Ãû£¬DB_PWDÌåÏÖÊý¾Ý¿âÃÜÂ룬DB_PORTÌåÏÖÊý¾Ý¿â¶Ë¿Ú£¬DB_PREFIXÌåÏÖÊý¾Ý¿â±íǰ׺¡£ÎÒÃÇ¿ÉÒÔƾ֤ÏÖÕæÏàÐÎÐÞ¸ÄÉÏÊö²ÎÊý¡£
ËÄ¡¢ÉèÖÃÄ£°åÒýÇæ
ʹÓÃÄ£°åÒýÇæ¿ÉÒÔÔÚThinkPHPÖн«Êý¾ÝʵÏÖ¶¯Ì¬äÖȾµ½ÍøÒ³ÖС£ÒÔÏ´úÂë¿ÉÔÚThinkPHPÖÐʹÓÃÀ´¾ÙÐÐÄ£°åÒýÇæÉèÖãº
'TMPL_PARSE_STRING'=>array( '__PUBLIC__'=>__ROOT__.'/Public', '__JS__'=>__ROOT__.'/Public/js', '__CSS__'=>__ROOT__.'/Public/css', '__IMG__'=>__ROOT__.'/Public/img' ),
µÇ¼ºó¸´ÖÆ
ÕâÀïµÄ__PUBLIC__£¬__JS__£¬__CSS__£¬__IMG__ÌåÏÖÏîÄ¿ÖÐʹÓõĹ«¹²Ä¿Â¼£¬JSĿ¼£¬CSSĿ¼ºÍͼÏñĿ¼£¬ÎÒÃÇ¿ÉÒÔƾ֤ÏÖÕæÏàÐξÙÐÐÐ޸ġ£Ï»®Ïß__ROOT__ÔòÊÇÖ¸ÏîÄ¿µÄ¸ùĿ¼¡£
ÒÔÉϾÍÊÇthinkphpÖг£ÓõÄÒýÈëÉèÖÃÓÐÄÄЩµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡