×ðÁú¿­Ê±

thinkphpÓï·¨ÔõôÕâô

ÄÑÃ÷£¿

ThinkPHP ÊÇÒ»¿î¿ªÔ´µÄ PHP ¿ª·¢¿ò¼Ü £¬ËüÌṩÁËÐí¶àÀû±ãµÄ¹¦Ð§ºÍ¹¤¾ß £¬Äܹ»´ó´óÌá¸ß PHP µÄ¿ª·¢Ð§ÂÊ¡£¿ÉÊÇ £¬ÔÚʹÓà ThinkPHP ¾ÙÐпª·¢µÄʱ¼ä £¬Ðí¶àÈ˾ͻáÓöµ½Ò»¸öÎÊÌ⣺thinkphp Óï·¨ÔõôÕâôÄÑÃ÷£¿

×Åʵ £¬thinkphp Óï·¨²¢²»ÊǺÜÄÑ £¬Ö»ÒªÄãÕÆÎÕÁËһЩ»ù±¾µÄ¿´·¨ºÍ¼¼ÇÉ £¬¾ÍÄܹ»ÇáËɵØʹÓÃËü¾ÙÐпª·¢¡£ÏÂÃæ £¬ÎÒÃǾÍÀ´Ò»ÆðÏàʶһÏ thinkphp µÄÓï·¨¡£

µÚÒ» £¬Ïàʶ MVC Éè¼Æģʽ

ÔÚʹÓà ThinkPHP ¾ÙÐпª·¢Ö®Ç° £¬Ê×ÏÈÒªÏàʶµÄÊÇËü½ÓÄɵÄÊÇ MVC Éè¼Æģʽ¡£MVC ÊÇÒ»ÖÖÈí¼þ¼Ü¹¹Ä£Ê½ £¬ÓÃÓÚ½«Ó¦ÓóÌÐòµÄÊäÈë¡¢´¦Öóͷ£ºÍÊä³öÊèÉ¢¿ªÀ´ £¬´Ó¶ø¸üºÃµØÖÎÀí´úÂëµÄ½á¹¹ºÍÂß¼­¡£ThinkPHP µÄ MVC Éè¼Æģʽ°üÀ¨Èý¸ö×é¼þ£º

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

Ä£×Ó£¨Model£©£ºÈÏÕæ´¦Öóͷ£Êý¾ÝµÄÔöɾ¸Ä²é²Ù×÷ £»

ÊÓͼ£¨View£©£ºÓÃÓÚÏÔʾÊý¾ÝºÍÓû§½çÃæ £¬Ö»¹ÜïÔÌ­Âß¼­´úÂëÓëÒ³Ãæ´úÂëµÄ»ìÔÓ £»

¿ØÖÆÆ÷£¨Controller£©£ºÖ÷ÒªÈÏÕæÓªÒµÂß¼­µÄ´¦Öóͷ£ £¬ÅþÁ¬ÊÓͼºÍÄ£×Ó¡£

ÏàʶÁË MVC Éè¼Æģʽ֮ºó £¬ÎÒÃǾͿÉÒÔ¸üºÃµØÃ÷È· thinkphp µÄ´úÂë½á¹¹ £¬´Ó¶øÔ½·¢ÇáËɵؿª·¢Ó¦ÓóÌÐò¡£

µÚ¶þ £¬ÕÆÎÕ thinkphp µÄ¿ØÖÆÆ÷

ThinkPHP µÄ¿ØÖÆÆ÷ÊÇÕû¸öÓ¦ÓóÌÐòµÄÈë¿Ú £¬ÈÏÕæÎüÊÕÓû§·¢³öµÄÇëÇó²¢¾ÙÐÐÏìÓ¦µÄ´¦Öóͷ£¡£ÔÚ¿ØÖÆÆ÷ÖÐ £¬¿ÉÒÔ½ç˵Ðí¶àÒªÁìÀ´´¦Öóͷ£²î±ðµÄÇëÇó¡£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔÔÚ¿ØÖÆÆ÷Öнç˵ index ÒªÁì £¬ÓÃÓÚÏÔʾÖ÷Ò³£º

<?php
namespace appindexcontroller;

class Index
{
    public function index()
    {
        return 'Hello,ThinkPHP5!';
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚä¯ÀÀÆ÷ÖÐÊäÈë http://localhost/index.php/Index/index ¾Í¿ÉÒÔ»á¼û¿ØÖÆÆ÷Öнç˵µÄ index ÒªÁìÁË¡£

µÚÈý £¬Ïàʶ thinkphp µÄÄ£×Ó

ÔÚ ThinkPHP ÖÐ £¬Ä£×ÓÓÃÓÚÓëÊý¾Ý¿â½»»¥ £¬¾ÙÐÐÊý¾ÝµÄÔöɾ¸Ä²é²Ù×÷¡£ÔÚʹÓÃÄ£×Ó֮ǰ £¬ÎÒÃÇÐèÒª¾ÙÐÐһЩÉèÖãº

ÔÚ application Ŀ¼Ï½¨ÉèÒ»¸ö model Ŀ¼ £»

ÔÚ model Ŀ¼Ï½¨ÉèÒ»¸ö User.php Îļþ £¬ÓÃÓÚ½ç˵Óû§Ä£×Ó¡£

<?php
namespace appmodel;

use thinkModel;

class User extends Model
{
    protected $table = 'user';

    public function getUserByPhone($phone)
    {
        return $this->where('phone', $phone)->find();
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖÐ £¬ÎÒÃǽç˵ÁËÒ»¸öÓû§Ä£×Ó User £¬²¢ÇÒ½ç˵ÁËÒ»¸ö getUserByPhone ÒªÁì £¬ÓÃÓÚƾ֤ÊÖ»úºÅÂëÅÌÎÊÓû§ÐÅÏ¢¡£ÔÚÒªÁìÖÐ £¬ÎÒÃÇʹÓÃÁË $this->where() ÒªÁìÀ´¾ÙÐÐÊý¾Ý¿âÅÌÎʲÙ×÷¡£

µÚËÄ £¬Ñ§Ï° thinkphp µÄÊÓͼ

ÔÚ ThinkPHP ÖÐ £¬ÊÓͼÓÃÓÚÏÔʾÊý¾ÝºÍÓû§½çÃæ¡£ÔÚ¿ØÖÆÆ÷ÖÐ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýÊÓͼÀ´Ïòä¯ÀÀÆ÷Êä³ö HTML ´úÂëºÍÊý¾Ý¡£ÀýÈ磺

<?php
namespace appindexcontroller;

class Index
{
    public function index()
    {
        $data = [
            'name' => 'ThinkPHP',
            'url' => 'https://www.thinkphp.cn/',
        ];
        return view('index', $data);
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖÐ £¬ÎÒÃÇͨ¹ý view() ÒªÁì¼ÓÔØÁËÒ»¸öÃûΪ index µÄÊÓͼ £¬Í¬Ê±×ª´ïÁËÒ»¸öÊý×é²ÎÊý $data¡£

ÊÓͼÖÐʹÓà À´Êä³ö PHP ±äÁ¿ºÍ´úÂë¡£ÀýÈç £¬ÔÚÊÓͼÖпÉÒÔÕâÑùÊä³ö $name ºÍ $url ±äÁ¿µÄÖµ£º

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title><?php echo $name ?></title>
</head>
<body>
    <h1><?php echo $name ?></h1>
    <a href="<?php echo $url ?>"><?php echo $url ?></a>
</body>
</html>

µÇ¼ºó¸´ÖÆ

µÚÎå £¬Ñ§Ï° thinkphp µÄ·ÓÉ

ÔÚ ThinkPHP ÖÐ £¬Â·ÓÉÊÇÖ¸½«Óû§ÇëÇóÖÐµÄ URL ·¾¶Ó³Éä³ÉÒ»¸ö¿ØÖÆÆ÷ÀàºÍÒªÁìµÄÀú³Ì¡£Â·ÓÉͨ³£ÓÐÁ½ÖÖ·½·¨£º

¾²Ì¬Â·ÓÉ£º½«Àο¿µÄ URL ·¾¶Ó³Éä³ÉÖ¸¶¨µÄ¿ØÖÆÆ÷ÀàºÍÒªÁì £»

¶¯Ì¬Â·ÓÉ£ºÆ¾Ö¤Óû§ÇëÇóÖеĶ¯Ì¬²ÎÊý £¬À´¶¯Ì¬Ó³Éä¿ØÖÆÆ÷ÀàºÍÒªÁì¡£

ÔÚ ThinkPHP ÖÐ £¬Â·Óɽç˵ÔÚ application/route.php ÎļþÖС£ÀýÈç £¬ÎÒÃÇ¿ÉÒÔÔÚ·ÓÉÎļþÖнç˵һ¸ö¼òÆӵķÓÉ£º

<?php
use thinkacadeRoute;

//¾²Ì¬Â·ÓÉ
Route::get('hello/:name', 'index/hello');

//¶¯Ì¬Â·ÓÉ
Route::get(':controller/:action', 'index/:controller/:action');

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÃæµÄ´úÂëÖÐ £¬ÎÒÃǽç˵ÁËÒ»¸ö¾²Ì¬Â·ÓɺÍÒ»¸ö¶¯Ì¬Â·ÓÉ¡£¾²Ì¬Â·ÓÉÖÐµÄ :name ²ÎÊý £¬ÊÇÒ»¸ö¶¯Ì¬²ÎÊý £¬¿ÉÒÔÔÚ¿ØÖÆÆ÷ÖÐͨ¹ý $request->param(‘name’) À´»ñÈ¡¡£¶¯Ì¬Â·ÓÉÖÐµÄ :controller ºÍ :action ²ÎÊý £¬Ôò»®·Ö¶ÔÓ¦ÁË¿ØÖÆÆ÷ºÍÒªÁìµÄÃû³Æ¡£

×ܽá

ͨ¹ýÉÏÃæµÄÏÈÈÝ £¬ÐÅÍи÷ÈË¶Ô thinkphp µÄÓï·¨Ó¦¸ÃÓÐÁËһЩÏàʶ¡£×Åʵ £¬thinkphp µÄÓï·¨²¢²»ÄÑ £¬Ö»ÒªÕÆÎÕÁËһЩ»ù´¡ÖªÊ¶ºÍ¼¼ÇÉ £¬¾ÍÄܹ»ÇáËɵؾÙÐпª·¢¡£ÈôÊÇÄãÏëÒªÔ½·¢ÉîÈëµØѧϰ thinkphp £¬¿ÉÒԲο¼¹Ù·½ÎĵµºÍÆäËûÏà¹Ø×ÊÁÏ¡£

ÒÔÉϾÍÊÇthinkphpÓï·¨ÔõôÕâôµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

13452372176

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

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

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