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

ÔõôÔÚThinkPHP¿ò¼ÜÖоÙÐпØÖÆÆ÷Ìøת

Ò»¡¢Ê¹ÓÃContorller¹¤¾ßµÄredirectÒªÁìʵÏÖÌøת

ʹÓÃController¹¤¾ßµÄredirectÒªÁì¿ÉÒÔÔÚThinkPHPÖÐʵÏÖÒ³ÃæÌøת¡£ÕâÖÖÒªÁìÔÊÐíʹÓÃÁ½¸ö²ÎÊý£ºµÚÒ»¸ö²ÎÊýÓÃÓÚÈ·¶¨ÌøתµÄURLµØµã £¬µÚ¶þ¸ö²ÎÊýÔòÖ¸¶¨ÔÚÌøתʱÐèҪת´ïµÄ²ÎÊýÐÅÏ¢¡£

ÏêϸµÄʵÏÖ°ì·¨ÈçÏ£º

ÔÚ¿ØÖÆÆ÷ÒªÁìÖÐŲÓÃredirectÒªÁì £¬ÀýÈ磺

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

public function index()
{
    // Ìøתµ½helloÒªÁì
    $this->redirect('hello');
}

µÇ¼ºó¸´ÖÆ

ÔÚÉèÖÃÎļþÖнç˵·ÓɹæÔò £¬ÀýÈ磺

// ·Óɽç˵
return [
    // Ìøת
    'hello' => 'index/hello',
];

µÇ¼ºó¸´ÖÆ

ÕâÀォhelloÓ³Éäµ½Index¿ØÖÆÆ÷µÄhelloÒªÁì¡£

ÔÚ¿ØÖÆÆ÷µÄhelloÒªÁìÖÐʵÏÖÌøת £¬ÀýÈ磺

public function hello()
{
    // Ìøתµ½/home/index/indexÒªÁì
    $this->redirect('/home/index/index',['id'=>1]);
}

µÇ¼ºó¸´ÖÆ

ÕâÀォÌøתµ½Home¿ØÖÆÆ÷µÄindexÒªÁì £¬²¢×ª´ïid²ÎÊýΪ1¡£

¶þ¡¢Ê¹ÓÃurlº¯ÊýºÍÒ³ÃæÌøתҪÁìʵÏÖÌøת

³ýÁËʹÓÃContorller¹¤¾ßµÄredirectÒªÁìʵÏÖÌøתÍâ £¬»¹¿ÉÒÔʹÓÃurlº¯ÊýºÍÒ³ÃæÌøתҪÁìʵÏÖÌøת¡£

ʹÓÃurlº¯ÊýʵÏÖÌøת£º

url('Ä£¿é/¿ØÖÆÆ÷/²Ù×÷',['²ÎÊý']);

µÇ¼ºó¸´ÖÆ

ʹÓÃÒ³ÃæÌøתҪÁìʵÏÖÌøת£º

$this->success('ÌáÐÑÐÅÏ¢', 'Ìøתurl');

µÇ¼ºó¸´ÖÆ

ÆäÖÐsuccessÒªÁì¿ÉÒÔ½ÓÊÜÈý¸ö²ÎÊý £¬»®·ÖÊÇÌáÐÑÐÅÏ¢¡¢ÌøתURLºÍÆÚ´ýʱ¼ä £¬Ä¬ÈÏÆÚ´ýʱ¼äΪ1Ãë¡£

ÏÂÃæ»®·ÖÏÈÈÝʹÓÃurlº¯ÊýºÍÒ³ÃæÌøתҪÁìʵÏÖÌøתµÄÏêϸʵÏÖ°ì·¨£º

ʹÓÃurlº¯ÊýʵÏÖÌøת £¬ÀýÈ磺

public function index()
{
    // Ìøתµ½Home¿ØÖÆÆ÷µÄindexÒªÁì
    $url = url('home/index/index',['id'=>1]);
    $this->assign('url', $url);
    return $this->fetch();
}

µÇ¼ºó¸´ÖÆ

ÕâÀォÌøתµ½Home¿ØÖÆÆ÷µÄindexÒªÁì £¬²¢×ª´ïid²ÎÊýΪ1¡£

ÔÚÒ³ÃæÖÐʹÓÃa±êǩʵÏÖÌøת£º

<a href="{$url}">Ìøת</a>

µÇ¼ºó¸´ÖÆ

ʹÓÃÒ³ÃæÌøתҪÁìʵÏÖÌøת £¬ÀýÈ磺

public function index()
{
    // Ìøתµ½Home¿ØÖÆÆ÷µÄindexÒªÁì
    $url = url('home/index/index',['id'=>1]);
    $this->success('ÌøתÀÖ³É', $url);
}

µÇ¼ºó¸´ÖÆ

Ìøתµ½Home¿ØÖÆÆ÷µÄindexÒªÁì £¬Í¬Ê±×ª´ïid²ÎÊýֵΪ1¡£Ò»ÃëÖÓºó £¬Ò³Ã潫×Ô¶¯Ìøתµ½Ô¤¶¨µÄURL £¬²¢ÏÔʾ¡°ÌøתÀֳɡ±µÄÌáÐÑ¡£

ÒÔÉϾÍÊÇÔõôÔÚThinkPHP¿ò¼ÜÖоÙÐпØÖÆÆ÷ÌøתµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ