ÔõôʹÓÃThinkPHP¿ò¼ÜÀ´ÊµÏÖÁ´½ÓµØµãµÄÒþ²Ø
ThinkPHPÊÇÒ»¸ö¿ªÔ´µÄPHP¿ª·¢¿ò¼Ü£¬ËüµÄÉè¼ÆÄ¿µÄÊǼòÆÓ¡¢ÎÞа¡¢¿ÉÀ©Õ¹¡£ÓÉÓÚÆäÇáÁ¿¼¶¡¢¸ßЧÐÔÒÔ¼°¶ÔMVC¼Ü¹¹µÄÖ§³ÖµÈÌص㣬¸Ã¿ò¼ÜÒѳÉΪ¿í´óPHP¿ª·¢ÕßµÄÊ×Ñ¡¡£
ÉèÖ÷ÓɹæÔò
ThinkPHPµÄ·Óɹ¦Ð§ºÜÊÇÇ¿Ê¢£¬¿ÉÒÔͨ¹ý·ÓɹæÔòʵÏÖÁ´½ÓµØµãµÄÒþ²Ø¡£ÔÚThinkPHPÖУ¬Â·ÓɹæÔòÊÇÓÃÓÚÆ¥ÅäURLµÄ£»ÉèÖ÷ÓɹæÔòÖ®ºó£¬Óû§»á¼ûÖ¸¶¨µÄURLʱ¿ÉÒÔ±»×ª·¢µ½Ö¸¶¨µÄ¿ØÖÆÆ÷ÒªÁìÖС£
ÀýÈ磬ÎÒÃÇ¿ÉÒÔÔÚ·ÓÉÎļþÖÐÌí¼ÓÒ»Ìõ¹æÔò£¬½«URL /myurl »á¼ûת·¢µ½Index¿ØÖÆÆ÷µÄindexÒªÁìÖУº
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
'__MYURL__' => 'index/index'
µÇ¼ºó¸´ÖÆ
ÕâÌõ¹æÔòÖУ¬__MYURL__ÊÇ×Ô½ç˵µÄα¾²Ì¬URL£¬¿ÉÒÔƾ֤ÐèÒªÉèÖã»index/indexÊÇÖ¸¶¨µÄ¿ØÖÆÆ÷ÒªÁì¡£
ʹÓÃÖض¨Ïò¹¦Ð§
Öض¨Ïò¹¦Ð§Ò²ÊÇThinkPHPÖÐʵÏÖÁ´½ÓµØµãÒþ²ØµÄÒ»ÖÖ·½·¨¡£ËüµÄÔÀíÊǽ«Óû§»á¼ûµÄURLÖض¨Ïòµ½Ò»¸öÒѾ±£´æµÄURLÉÏ£¬´Ó¶øÒþ²ØÕæʵµÄÁ´½ÓµØµã¡£
ÀýÈ磬ÎÒÃÇ¿ÉÒÔÔÚÒ»¸öÍøÒ³ÖÐÌí¼ÓÒ»¸öÁ´½Ó£¬Á´½ÓµØµãΪ http://www.example.com/link.php¡£µ±Óû§µã»÷¸ÃÁ´½Óʱ£¬¿ÉÒÔʹÓÃÏÂÃæµÄ´úÂ뽫ÆäÖض¨Ïòµ½ÒѾ±£´æµÄURL http://www.example.com/index.phpÉÏ£º
header('Location: http://www.example.com/index.php');
µÇ¼ºó¸´ÖÆ
ʹÓÃURLµØµãÆÊÎö·½·¨
ThinkPHPÌṩÁËÒ»¸ö U()º¯Êý£¬¿ÉÒÔ½«URLµØµãÆÊÎö³É·ÓɹæÔòʵÏÖÁ´½ÓµØµãµÄÒþ²Ø¡£Ê¹Óøú¯ÊýÐèÒªÔÚÆôÓ÷Óɹ¦Ð§µÄÇéÐÎÏ¡£
ÀýÈ磬ÎÒÃÇ¿ÉÒÔ½« /url ת»¯ÎªÂ·ÓɹæÔò index/index£¬²¢ÌìÉúÒþ²ØµÄÁ´½ÓµØµã£º
$url = U('index/index'); echo '<a href="' . $url . '">Á´½ÓµØµã</a>';
µÇ¼ºó¸´ÖÆ
ͨ¹ýÉÏÊöÒªÁ죬ÎÒÃǾÍÄܹ»½«Á´½ÓµØµã¾ÙÐÐÒþ²Ø£¬ÌáÉýÓû§µÄ»á¼ûÇå¾²ÐÔ£¬Í¬Ê±Ò²Äܹ»ïÔ̶ñÒâ»á¼ûÕ߶ÔÍøÕ¾µÄ¹¥»÷¡£
ÒÔÉϾÍÊÇÔõôʹÓÃThinkPHP¿ò¼ÜÀ´ÊµÏÖÁ´½ÓµØµãµÄÒþ²ØµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡