尊龙凯时人生就是搏

thinkphpÔõÑù°ó¶¨Ä£¿é

Ëæ×Å»¥ÁªÍøÊÖÒÕµÄÒ»Ö±Éú³¤£¬Ô½À´Ô½¶àµÄÍøÕ¾ºÍÓ¦ÓóÌÐò½ÓÄÉÁËmvcģʽ×÷ΪÉè¼Æ¿ò¼Ü£¬ÆäÖÐÒÔthinkphpΪ´ú±íµÄphp¿ò¼Ü£¬ÊÇmvcģʽÖнÏÁ¿ÊܽӴýµÄÒ»ÖÖ¡£ÔÚthinkphp¿ò¼ÜÖУ¬Ä£¿éÊÇÒ»¸öºÜÊÇÖ÷ÒªµÄ¿´·¨£¬Í¨¹ýÄ£¿é¿ÉÒÔ½«Ó¦ÓóÌÐòÖ§½â³É²î±ðµÄ¹¦Ð§Ä£¿é£¬±ãÓÚÖÎÀíºÍά»¤¡£¿ÉÊdzõѧÕß¿ÉÄÜ»áÓöµ½Ò»¸öÎÊÌ⣬¾ÍÊÇÔõÑù°ó¶¨Ä£¿é£¬ÏÂÃæÎÒÃǽ«ÏêϸÏÈÈÝthinkphpÔõÑù°ó¶¨Ä£¿é¡£

Ò»¡¢½¨ÉèÄ£¿é

ÔÚ×îÏÈ°ó¶¨Ä£¿é֮ǰ£¬ÎÒÃÇÏÈÀ´½¨ÉèÒ»¸öÄ£¿é¡£ÒÔ½¨ÉèÒ»¸öÃûΪBlogµÄÄ£¿éΪÀý£¬ÎÒÃÇÐèÒªÔÚThinkPHP¿ò¼ÜµÄÓ¦ÓóÌÐòĿ¼Ï½¨ÉèÒ»¸öÃûΪBlogµÄĿ¼£¬È»ºóÔÚBlogĿ¼Ï½¨ÉèÒ»¸öÃûΪIndexµÄ¿ØÖÆÆ÷ºÍÒ»¸öÃûΪindex.htmlµÄÄ£°åÎļþ¡£Ïêϸ²Ù×÷ÈçÏ£º

·­¿ªThinkPHPµÄÓ¦ÓóÌÐòĿ¼£¬Ò»Ñùƽ³£ÇéÐÎÏÂÊÇÔÚwwwĿ¼ÏµÄÒ»¸öÃûΪApplicationµÄĿ¼¡£

ÔÚÓ¦ÓóÌÐòĿ¼Ï½¨ÉèÒ»¸öÃûΪBlogµÄĿ¼£¬Ä¿Â¼Ãû±ØÐèºÍÄ£¿éÃûÏàͬ¡£

ÔÚBlogĿ¼Ï½¨ÉèÒ»¸öÃûΪIndexµÄ¿ØÖÆÆ÷Îļþ£¬¿ØÖÆÆ÷ÎļþÃû±ØÐèºÍ¿ØÖÆÆ÷ÀàÃûÏàͬ£¨ÔÚ±¾ÀýÖУ¬¿ØÖÆÆ÷ÀàÃûΪIndexController£¬ÎļþÃûΪIndexController.class.php£©¡£

ÔÚIndex¿ØÖÆÆ÷ÎļþÖÐÌí¼ÓÒ»¸öÃûΪindexµÄÒªÁ죬ÓÃÓÚ´¦ÀíÍøÒ³ÇëÇó¡£

ÔÚBlogĿ¼Ï½¨ÉèÒ»¸öÃûΪindex.htmlµÄÄ£°åÎļþ£¬ÓÃÓÚÏÔʾÍøÒ³ÄÚÈÝ¡£

´úÂëʾÀý£º

¿ØÖÆÆ÷ÎļþIndexController.class.php£º

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

<?php
namespace BlogController;
use ThinkController;

class IndexController extends Controller {
    public function index(){
        $this->display();
    }
}

µÇ¼ºó¸´ÖÆ

Ä£°åÎļþindex.html£º

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Blog</title>
</head>
<body>
    <h1>Welcome to my blog!</h1>
</body>
</html>

µÇ¼ºó¸´ÖÆ

¶þ¡¢°ó¶¨Ä£¿é

½¨ÉèºÃÁËBlogÄ£¿éÖ®ºó£¬ÎÒÃÇÐèÒª½«ÆäÓëÓ¦ÓóÌÐò¾ÙÐа󶨣¬ÈÃϵͳ֪µÀÓ¦¸Ã»á¼ûÄĸöÄ£¿é£¬Ïêϸ²Ù×÷ÈçÏ£º

·­¿ªÓ¦ÓóÌÐòĿ¼ÏµÄÉèÖÃÎļþconfig.php¡£

ÕÒµ½ÉèÖÃÏîDEFAULT_MODULE£¬²¢½«ÆäÖµÐÞ¸ÄΪBlog¡£

ÉúÑÄÐ޸ĺóµÄÉèÖÃÎļþ¡£

´úÂëʾÀý£º

config.phpÎļþ£º

<?php
return array(
    'DEFAULT_MODULE'     => 'Blog', // ĬÈÏÄ£¿éÃû
    ...
);

µÇ¼ºó¸´ÖÆ

ÐÞ¸ÄÍêÉèÖÃÎļþÖ®ºó£¬¿ÉÒÔͨ¹ýÒÔÏÂURL»á¼ûBlogÄ£¿é£º

http://yourdomain/Blog

Èý¡¢°ó¶¨×ÓÄ£¿é

ÓÐЩʱ¼ä£¬ÎÒÃÇÐèÒª½«Ò»¸öÄ£¿é²ð·Ö³É¶à¸ö×ÓÄ£¿é£¬ÀýÈçÔÚBlogÄ£¿éÖУ¬ÎÒÃÇ¿ÉÒÔ½«ÎÄÕÂÁбíºÍÎÄÕÂÏêÇéÒ³»®·Ö½¨ÉèΪ²î±ðµÄ×ÓÄ£¿é¡£Ïêϸ²Ù×÷ÈçÏ£º

ÔÚBlogĿ¼Ï½¨ÉèÒ»¸öÃûΪArticleµÄĿ¼¡£

ÔÚArticleĿ¼Ï½¨ÉèÒ»¸öÃûΪIndexµÄ¿ØÖÆÆ÷ºÍÒ»¸öÃûΪlist.htmlµÄÄ£°åÎļþ£¬ÓÃÓÚÏÔʾÎÄÕÂÁбí¡£

ÔÚArticleĿ¼Ï½¨ÉèÒ»¸öÃûΪDetailsµÄ¿ØÖÆÆ÷ºÍÒ»¸öÃûΪindex.htmlµÄÄ£°åÎļþ£¬ÓÃÓÚÏÔʾÎÄÕÂÏêÇéÒ³¡£

¿ØÖÆÆ÷ÎļþArticle/IndexController.class.php£º

<?php
namespace BlogControllerArticle;
use ThinkController;

class IndexController extends Controller {
    public function index(){
        $this->display();
    }
}

µÇ¼ºó¸´ÖÆ

¿ØÖÆÆ÷ÎļþArticle/DetailsController.class.php£º

<?php
namespace BlogControllerArticle;
use ThinkController;

class DetailsController extends Controller {
    public function index(){
        $this->display();
    }
}

µÇ¼ºó¸´ÖÆ

Ä£°åÎļþArticle/list.html£º

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Article List</title>
</head>
<body>
    <h1>Article List</h1>
</body>
</html>

µÇ¼ºó¸´ÖÆ

Ä£°åÎļþArticle/index.html£º

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Article Details</title>
</head>
<body>
    <h1>Article Details</h1>
</body>
</html>

µÇ¼ºó¸´ÖÆ

·­¿ªÓ¦ÓóÌÐòĿ¼ÏµÄÉèÖÃÎļþconfig.php¡£

ÕÒµ½ÉèÖÃÏîURL_CASE_INSENSITIVE£¬²¢½«ÆäÖµÐÞ¸ÄΪtrue£¬Ê¹URL¶Ô¾Þϸд²»Ãô¸Ð¡£

ÕÒµ½ÉèÖÃÏîMODULE_ALLOW_LIST£¬²¢½«ÆäÖµÐÞ¸ÄΪBlog, Blog/Article£¬ÔÊÐí»á¼ûBlogºÍBlog/ArticleÁ½¸öÄ£¿é¡£

ÉúÑÄÐ޸ĺóµÄÉèÖÃÎļþ¡£

´úÂëʾÀý£º

config.phpÎļþ£º

<?php
return array(
    'DEFAULT_MODULE'     => 'Blog', // ĬÈÏÄ£¿éÃû
    'URL_CASE_INSENSITIVE'  => true, // URL²»Çø·Ö¾Þϸд
    'MODULE_ALLOW_LIST' => array('Blog','Blog/Article'), // ÔÊÐí»á¼ûµÄÄ£¿é
    ...
);

µÇ¼ºó¸´ÖÆ

ÐÞ¸ÄÍêÉèÖÃÎļþÖ®ºó£¬¿ÉÒÔͨ¹ýÒÔÏÂURL»á¼ûArticle×ÓÄ£¿é£º

http://yourdomain/Blog/Article/index

http://yourdomain/Blog/Article/details

°ó¶¨×ÓÄ£¿éʱÐèҪעÖصÄÊÇ£¬¿ØÖÆÆ÷ºÍÄ£°åÎļþ±ØÐèƾ֤·Ö×é·½·¨´æ·Å£¬¿ØÖÆÆ÷ÀàÃûÐèÒªÌí¼Ó·Ö×éǰ׺£¬ÀýÈçÔÚ±¾ÀýÖпØÖÆÆ÷ÀàµÄÃüÃû¿Õ¼äΪBlogControllerArticle¡£Í¬Ê±£¬ÉèÖÃÎļþÖÐÐèÒª½«ÔÊÐí»á¼ûµÄÄ£¿éÏÞÖÆΪ¸¸¼¶Ä£¿éºÍ×Ó¼¶Ä£¿é¡£

ËÄ¡¢×ܽá

°ó¶¨Ä£¿éÊÇThinkPHP MVCģʽÖеÄÒ»¸öºÜÊÇÖ÷ÒªµÄ»·½Ú£¬Í¨¹ý°ó¶¨Ä£¿é¿ÉÒÔ½«Ó¦ÓóÌÐò²ð·Ö³É¶à¸ö¹¦Ð§Ä£¿é£¬½«´úÂëÂß¼­ºÍ½á¹¹ÊèÉ¢£¬±ãÓÚÖÎÀíºÍά»¤¡£±¾ÎÄ´Ó½¨ÉèÄ£¿é¡¢°ó¶¨Ä£¿éµ½°ó¶¨×ÓÄ£¿é£¬¶ÔThinkPHPÔõÑù°ó¶¨Ä£¿é¾ÙÐÐÁËÏêϸÏÈÈÝ£¬Ï£ÍûÄܹ»¶Ô³õѧÕßÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇthinkphpÔõÑù°ó¶¨Ä£¿éµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ