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

thinkphpÐÞ¸ÄÌøת

ÔÚʹÓÃthinkphp¿ò¼Üʱ£¬ÎÒÃǾ­³£ÐèÒª¾ÙÐÐÌøת²Ù×÷¡£Ä¬ÈÏÇéÐÎÏ£¬thinkphpµÄÌøתº¯ÊýÊÇÌøתµ½Ö¸¶¨urlµØµã£¬ÀýÈ磺

$this->redirect('http://www.example.com');

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

µ«ÓÐʱ¼ä£¬ÎÒÃÇÐèÒªÔÚÌøתʱ¾ÙÐÐһЩÌØÁíÍâ²Ù×÷»òÕßÐÞ¸ÄĬÈϵÄÌøת·½·¨¡£±¾ÎĽ«ÏÈÈÝÔõÑùÐÞ¸ÄThinkPHPÌøת·½·¨¡£

ÐÞ¸ÄÌøת·½·¨

ÔÚThinkPHPÖУ¬Ìøתº¯ÊýÓÐÁ½ÖÖ·½·¨£ºredirectºÍsuccess/error¡£

redirectº¯Êý

redirectº¯ÊýÊÇThinkPHP¿ò¼ÜÌṩµÄĬÈÏÌøתº¯Êý£¬ËüÓÃÓÚÌøתµ½Ö¸¶¨URLµØµã¡£

$this->redirect('http://www.example.com');

µÇ¼ºó¸´ÖÆ µÇ¼ºó¸´ÖÆ

redirectº¯ÊýµÄµÚÒ»¸ö²ÎÊýÊÇÒªÌøתµÄURLµØµã£¬ÈôÊÇÒªÌøתµ½Ä¿½ñ¿ØÖÆÆ÷µÄij¸öÒªÁ죬¿ÉÒÔʹÓÃUº¯ÊýÌìÉúURLµØµã£º

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

$this->redirect(U('index'));

µÇ¼ºó¸´ÖÆ

¿ÉÒÔͨ¹ýµÚ¶þ¸ö²ÎÊýÀ´ÉèÖÃÌøתÑÓ³Ùʱ¼ä£º

$this->redirect(U('index'), 3, 'ÌøתÖÐ...');

µÇ¼ºó¸´ÖÆ

redirectº¯ÊýµÄµÚÈý¸ö²ÎÊýÊÇÌáÐÑÐÅÏ¢£¬ÈôÊÇÉèÖÃÁ˸òÎÊý£¬Ôò»áÔÚÌøתǰÊä³öÌáÐÑÐÅÏ¢¡£

redirectº¯ÊýÊÇthinkControllerÀàÖеĺ¯Êý£¬ÔÚÆäËûÀàÖпÉÒÔʹÓÃ$this->redirect()¾ÙÐÐÌøת¡£

successºÍerrorº¯Êý

successºÍerrorº¯ÊýÓÃÓÚÌøתµ½¿ò¼Ü×Ô´øµÄÀֳɺ͹ýʧҳÃæ¡£ËüÃǵÄÓ÷¨ÈçÏ£º

$this->success('²Ù×÷ÀÖ³É', U('index'));
$this->error('²Ù×÷ʧ°Ü', U('index'));

µÇ¼ºó¸´ÖÆ

µÚÒ»¸ö²ÎÊýÊÇÌáÐÑÐÅÏ¢£¬µÚ¶þ¸ö²ÎÊýÊÇÌøתµØµã£¬ÈôÊDz»ÉèÖÃÌøתµØµã£¬ÔòĬÈÏÌøתµ½ÉÏÒ»´Î»á¿´·¨Ö·¡£

ÐÞ¸ÄÌøת·½·¨

ĬÈÏÇéÐÎÏ£¬ThinkPHP¿ò¼ÜÌøתº¯ÊýÊÇʹÓÃHeaderº¯Êý¾ÙÐÐÌøת£¬Ò²¾ÍÊÇÖ±½ÓÌøתµ½Ö¸¶¨URLµØµã¡£µ«ÔÚijЩÇéÐÎÏ£¬ÎÒÃÇÐèÒª¸Ä±äÌøת·½·¨£¬ÀýÈçÔÚÌøתǰÐèÒªÖ´ÐÐijЩ²Ù×÷£¬»òÕßÔÚÌøתʱÐèҪת´ïһЩ²ÎÊýµÈ¡£

ThinkPHP¿ò¼ÜÌṩÁËÒ»¸öredirectÒªÁ죬ÓÃÓÚÐÞ¸ÄÌøת·½·¨¡£ÔÚÌøתǰÏÈÖ´ÐÐijЩ²Ù×÷ÒÔ¼°×ª´ï²ÎÊýµÈ²Ù×÷ºóÔÙÌøת¡£

$this->redirect('jump', array('id'=>1), 2, 'ÌøתÖÐ...');

µÇ¼ºó¸´ÖÆ

ÒÔÉÏ´úÂ뽫»áŲÓÃjumpÒªÁ죺

public function jump($id){
    // do something
    $this->redirect('http://www.example.com');
}

µÇ¼ºó¸´ÖÆ

ÎÒÃÇ¿ÉÒÔÔÚjumpÒªÁìÖоÙÐÐһЩ²Ù×÷£¬ÀýÈçÅÌÎÊÊý¾Ý¿â¡¢ÉèÖÃSessionµÈ¡£È»ºóÔÚÌøתʱÔÙ¾ÙÐÐÌøת²Ù×÷¡£

redirectÒªÁìµÄµÚÒ»¸ö²ÎÊýÊÇÒªÌøתµÄÒªÁ죬µÚ¶þ¸ö²ÎÊýÊÇҪת´ïµÄ²ÎÊý£¬µÚÈý¸ö²ÎÊýÊÇÌøתʱ¼ä£¬µÚËĸö²ÎÊýÊÇÌøתʱµÄÌáÐÑÐÅÏ¢¡£

×ܽá

ÔÚThinkPHP¿ò¼ÜÖУ¬Ìøת¹¦Ð§·Ç¾­³£Ó㬲¢ÇÒºÜÊÇÎÞа¡£Í¨¹ýÐÞ¸ÄÌøת·½·¨£¬ÎÒÃÇ¿ÉÒÔÔÚÌøתǰ¾ÙÐÐһЩ²Ù×÷£¬Ê¹µÃÌøתԽ·¢ÖÇÄÜ»¯¡£ÉÏÊö¾ÍÊÇÎÒ¹ØÓÚThinkPHPÐÞ¸ÄÌøתµÄ×ܽá¡£

ÒÔÉϾÍÊÇthinkphpÐÞ¸ÄÌøתµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ