×ðÁú¿­Ê±¹ÙÍøµÇ¼

thinkphp5.0¿çÄ £¿éÔõôÌøת

thinkphpÊÇÒ»¸ö»ùÓÚmvc£¨model-view-controller£©¼Ü¹¹µÄphp¿ò¼Ü £¬¿ÉÓÃÓÚwebÓ¦ÓóÌÐòµÄ¿ª·¢ ¡£ÔÚthinkphpÖÐ £¬Ä £¿éµÄ¿´·¨±»ÆÕ±éÔËÓà ¡£ÔÚһЩÖØ´óµÄÓ¦ÓóÌÐòÖÐ £¬ÐèÒªÔÚ²î±ðµÄÄ £¿éÖ®¼ä¾ÙÐÐÌøת ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃthinkphp5.0¾ÙÐпçÄ £¿éµÄÌøת ¡£

¸ÅÊö

¿çÄ £¿éÌøתÊÇÖ¸´ÓÒ»¸öÄ £¿éµÄ¿ØÖÆÆ÷Ìøתµ½ÁíÒ»¸öÄ £¿éµÄ¿ØÖÆÆ÷ ¡£ÔÚthinkPHPÖÐ £¬Ã¿¸öÄ £¿é¶¼ÓÐ×ÔÁ¦µÄ¿ØÖÆÆ÷ºÍÊÓͼ ¡£ÔÚ¾ÙÐÐÌøתǰ £¬ÐèÒªÏȽç˵ºÃ·ÓɹæÔò ¡£

½ç˵·ÓɹæÔò

ÔÚthinkPHP5.0ÖÐ £¬¿ÉÒÔÔÚ·ÓÉÎļþ£¨route.php£©Öнç˵·ÓɹæÔò ¡£ÔÚ·ÓɹæÔòÖÐ £¬¿ÉÒÔ½ç˵¶ÔURLÇëÇóµÄÏìÓ¦ £¬°üÀ¨¿çÄ £¿éÌøת ¡£

½ç˵·ÓɹæÔòµÄÃûÌÃÈçÏ£º

Route::rule('·ÓɹæÔò','Ä£¿é/¿ØÖÆÆ÷/ÒªÁì','ÇëÇóÀàÐÍ');

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬Â·ÓɹæÔòΪ×Ö·û´®ÀàÐÍ £¬Ä £¿é/¿ØÖÆÆ÷/ÒªÁìΪ¶ÔURLÇëÇóµÄÏìÓ¦ £¬ÇëÇóÀàÐÍΪHTTPÒªÁì £¬ÀýÈ磺

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

Route::rule('index','index/Index/index','get');

µÇ¼ºó¸´ÖÆ

Õâ¸ö¹æÔòÌåÏÖ £¬µ±ÇëÇóµÄURLΪhttp://www.example.com/indexʱ £¬ÏìÓ¦µÄ¿ØÖÆÆ÷ΪIndex¿ØÖÆÆ÷ϵÄindexÒªÁì £¬²¢ÇÒÇëÇóÀàÐÍΪget ¡£

ÔÚ¾ÙÐпçÄ £¿éÌøתʱ £¬¿ÉÒÔÔÚ·ÓɹæÔòÖÐʹÓÃÏ»®Ïß¡°_¡±ÌåÏÖÄ £¿éÃû³Æ ¡£ÀýÈ磺

Route::rule('jump','admin_Ä£¿é/¿ØÖÆÆ÷/ÒªÁì','get');

µÇ¼ºó¸´ÖÆ

Õâ¸ö¹æÔòÌåÏÖ £¬µ±ÇëÇóµÄURLΪhttp://www.example.com/jumpʱ £¬ÏìÓ¦µÄ¿ØÖÆÆ÷ΪadminÄ £¿éϵĿØÖÆÆ÷µÄÒªÁì £¬²¢ÇÒÇëÇóÀàÐÍΪget ¡£

ÔÚ½ç˵ºÃ·ÓɹæÔòºó £¬¾Í¿ÉÒÔ¾ÙÐпçÄ £¿éÌøתÁË ¡£

¿çÄ £¿éÌøת

ÔÚthinkPHP5.0ÖÐ £¬¿ÉÒÔʹÓÃϵͳÌṩµÄUrlÖúÊÖº¯Êý¾ÙÐпçÄ £¿éÌøת ¡£UrlÖúÊÖº¯Êý¿ÉÒÔƾ֤½ç˵ºÃµÄ·ÓɹæÔòÌìÉú¶ÔÓ¦µÄURLµØµã ¡£

ʹÓÃUrlÖúÊÖº¯ÊýµÄÃûÌÃÈçÏ£º

url('·ÓɹæÔò',²ÎÊýÊý×é);

µÇ¼ºó¸´ÖÆ

ÆäÖÐ £¬Â·ÓɹæÔòΪ½ç˵ºÃµÄ·ÓɹæÔò £¬²ÎÊýÊý×éΪת´ï¸øÄ¿µÄ¿ØÖÆÆ÷µÄ²ÎÊýÊý×é ¡£

ÀýÈç £¬ÔÚÖ÷Ä £¿éIndex¿ØÖÆÆ÷ÖÐ £¬ÐèÒªÌøתµ½adminÄ £¿éϵÄUser¿ØÖÆÆ÷µÄaddÒªÁì £¬¿ÉÒÔÕâÑùд£º

public function jump(){
    // Ìøתµ½adminÄ£¿éϵÄUser¿ØÖÆÆ÷µÄaddÒªÁì
    $url = url('admin_User/add');
    return $this->redirect($url);
}

µÇ¼ºó¸´ÖÆ

ÔÚÌøתʱ £¬ÈôÊÇÐèҪת´ï²ÎÊý £¬¿ÉÒÔÔÚUrlÖúÊÖº¯ÊýµÄµÚ¶þ¸ö²ÎÊýÖÐÌí¼Ó ¡£ÀýÈç £¬ÔÚIndex¿ØÖÆÆ÷ÖÐÐèÒªÌøתµ½adminÄ £¿éϵÄUser¿ØÖÆÆ÷µÄeditÒªÁì £¬²¢×ª´ï²ÎÊýid=1 £¬¿ÉÒÔÕâÑùд£º

public function jump(){
    // Ìøתµ½adminÄ£¿éϵÄUser¿ØÖÆÆ÷µÄeditÒªÁì£¬²¢×ª´ï²ÎÊýid=1
    $url = url('admin_User/edit',['id'=>1]);
    return $this->redirect($url);
}

µÇ¼ºó¸´ÖÆ

ÔÚÄ¿µÄ¿ØÖÆÆ÷ÖÐ £¬¿ÉÒÔʹÓÃinput()º¯Êý»ñÈ¡²ÎÊýÖµ ¡£ÀýÈç £¬ÔÚUser¿ØÖÆÆ÷µÄeditÒªÁìÖÐ £¬»ñÈ¡id²ÎÊýÖµµÄ´úÂëÈçÏ£º

public function edit(){
    // »ñÈ¡id²ÎÊýÖµ
    $id = input('id');
    // ¸³Öµµ½ÊÓͼÖÐ
    $this->assign('id',$id);
    // äÖȾÊÓͼ
    return $this->fetch();
}

µÇ¼ºó¸´ÖÆ

×ܽá

±¾ÎÄÏÈÈÝÁËÔõÑùʹÓÃthinkPHP5.0¾ÙÐпçÄ £¿éµÄÌøת ¡£ÔÚ¾ÙÐÐÌøתǰ £¬ÐèÒªÏȽç˵ºÃ·ÓɹæÔò £¬È»ºóʹÓÃUrlÖúÊÖº¯ÊýÌìÉúÌøתµÄURLµØµã ¡£ÔÚÄ¿µÄ¿ØÖÆÆ÷ÖÐ £¬¿ÉÒÔʹÓÃinput()º¯Êý»ñÈ¡Ìøתʱת´ïµÄ²ÎÊýÖµ ¡£

ÒÔÉϾÍÊÇthinkphp5.0¿çÄ £¿éÔõôÌøתµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

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

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

QR code
ÍøÕ¾µØͼ