thinkphpÖеÄu()ÒªÁìÔõôʹÓÃ
ThinkPHPÊÇÒ»ÖÖ¹ãÊܽӴýµÄPHP¿ª·¢¿ò¼Ü£¬Äܹ»Îª¿ª·¢Ö°Ô±ÌṩÖÚ¶à±ã½ÝµÄ¹¤¾ßºÍ¹¦Ð§¡£UÒªÁìÊÇÒ»ÖÖÊ®·ÖÊÊÓõļ¼ÇÉ£¬Äܹ»ÓÃÓÚ½¨ÉèURLÁ´½Ó²¢´«Êä²ÎÊý¡£
ͨ¹ýʹÓÃUÒªÁìÔÚThinkPHPÖÐÌìÉú´øÓвÎÊýµÄURLµØµã£¬ÒÔÀû±ãÒ³Ãæ¼äµÄÌøתºÍ²ÎÊýת´ï¡£ÔÚUÒªÁìÖУ¬¿ÉÒÔʹÓÃÏÂÃæµÄ²ÎÊý£º
Ä£¿éÃû
¿ØÖÆÆ÷Ãû
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
²Ù×÷Ãû
²ÎÊý
URL²ÎÊý
UÒªÁìµÄ»ù±¾Óï·¨ÈçÏ£º
U('Ä£¿é/¿ØÖÆÆ÷/²Ù×÷','²ÎÊý','URL²ÎÊý');
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öÓï·¨ÖУ¬Ä£¿éÃû¡¢¿ØÖÆÆ÷ÃûºÍ²Ù×÷ÃûÊDZØÐèµÄ£¬²ÎÊýºÍURL²ÎÊý¶¼ÊÇ¿ÉÑ¡µÄ¡£
¹ØÓÚÄ£¿éÃû¡¢¿ØÖÆÆ÷ÃûºÍ²Ù×÷Ãû£¬¿ÉÒÔͨ¹ýдÈë¶ÔÓ¦µÄ×Ö·û´®À´¾ÙÐд«È룬ÀýÈ磺
U('Home/Index/index');
µÇ¼ºó¸´ÖÆ
ʹÓÃÕâÖÖ·½·¨¿ÉÒÔÌìÉúÒ»¸öÖ¸Ïòindex²Ù×÷µÄÁ´½ÓµØµã¡£
¹ØÓÚ²ÎÊý£¬¿ÉÒÔ½«Æäд³É¹Å°åµÄURL²ÎÊýÐÎʽ£¬ÀýÈ磺
U('Home/Index/index', 'id=1&name=test');
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öÁ´½ÓµØµãÖУ¬idºÍname¶¼ÊDzÎÊýµÄÃû³Æ£¬1ºÍtestÊDzÎÊýµÄÖµ¡£
³ý´ËÖ®Í⣬»¹¿ÉÒÔʹÓÃÊý×éµÄ·½·¨À´×ª´ï²ÎÊý£º
U('Home/Index/index', array('id' => 1, 'name' => 'test'));
µÇ¼ºó¸´ÖÆ
ÔÚÕâ¸öÀý×ÓÖУ¬idºÍname¶¼ÊÇÊý×é¼üµÄÃû³Æ£¬1ºÍtestÊÇÊý×é¼ü¶ÔÓ¦µÄÖµ¡£
×îºó£¬»¹¿ÉÒÔʹÓÃURL²ÎÊý£¬ÀýÈ磺
U('Home/Index/index', '', 'id=1');
µÇ¼ºó¸´ÖÆ
ÕâÑù£¬¾Í¿ÉÒÔÔÚÁ´½ÓµØµãºóÃæÌí¼Óid=1Õâ¸öURL²ÎÊý¡£
ÔÚÏÖʵ¿ª·¢ÖУ¬UÒªÁìµÄʹÓó¡¾°ºÜÊÇÆձ顣ÀýÈ磬ÔÚ¿ØÖÆÆ÷ÖУ¬¿ÉÒÔʹÓÃUÒªÁìÀ´ÌìÉú²Ëµ¥Á´½Ó£º
$this->assign('menu', array( 'Ê×Ò³' => U('Home/Index/index'), '¹ØÓÚ×ðÁú¿Ê±¹ÙÍøµÇ¼' => U('Home/About/index'), 'ÁªÏµ×ðÁú¿Ê±¹ÙÍøµÇ¼' => U('Home/Contact/index') ));
µÇ¼ºó¸´ÖÆ
ÔÚÒ³ÃæÖÐʹÓÃÑ»·Êä³ö²Ëµ¥£º
<ul> <?php foreach($menu as $name => $url): ?> <li><a href="<?php echo $url; ?>"><?php echo $name; ?></a></li> <?php endforeach; ?> </ul>
µÇ¼ºó¸´ÖÆ
ͨ¹ýÕâÖÖ·½·¨£¬¾Í¿ÉÒÔ¿ìËÙµØÌìÉú²Ëµ¥Á´½Ó£¬ÒÔÀû±ãÓû§»á¼ûÒ³Ãæ¡£
ÒÔÉϾÍÊÇthinkphpÖеÄu()ÒªÁìÔõôʹÓõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡