尊龙凯时人生就是搏

thinkphp3.2.3 uÒªÁì´«²ÎÊý

thinkphp3.2.3ÊÇÒ»¸öÊ¢ÐеĿªÔ´php¿ò¼Ü£¬Ëü¿ÉÒÔÀû±ãµØ¿ª·¢webÓ¦ÓóÌÐò£¬²¢ÌṩÁ˸»ºñµÄÓ¦ÓóÌÐò¿ª·¢¹¦Ð§¡£ÔÚthinkphp3.2.3ÖУ¬uÒªÁìÊÇÒ»¸ö·Ç¾­³£Óõĺ¯Êý£¬ÓÃÓÚÌìÉúurl·¾¶£¬ÔÚʹÓÃuÒªÁìʱ£¬ÎÒÃÇ¿ÉÄÜÐèÒªÏòurlÖÐת´ïһЩ²ÎÊý£¬±¾ÎĽ«ÏÈÈÝÔõÑùÔÚthinkphp3.2.3ÖÐʹÓÃuÒªÁìת´ï²ÎÊý¡£

Ò»¡¢uÒªÁìÏÈÈÝ

ÔÚThinkphp3.2.3ÖУ¬uÒªÁìÓÃÓÚÌìÉúURL·¾¶£¬ÆäÓï·¨ÈçÏ£º

u('¿ØÖÆÆ÷/²Ù×÷ÒªÁì', '²ÎÊý', 'α¾²Ì¬ºó׺', 'ÊÇ·ñÏÔʾÓòÃû')

µÇ¼ºó¸´ÖÆ

ÆäÖУ¬¿ØÖÆÆ÷/²Ù×÷ÒªÁìÖ¸¶¨ÒªÌìÉúµÄURL·¾¶µÄ¿ØÖÆÆ÷ºÍ²Ù×÷ÒªÁ죬²ÎÊýÖ¸¶¨Òª×ª´ï¸ø²Ù×÷ÒªÁìµÄ²ÎÊý£¬Î±¾²Ì¬ºó׺ָ¶¨ÌìÉúµÄURLµÄºó׺£¨Èç.html£©£¬ÊÇ·ñÏÔʾÓòÃûÖ¸¶¨ÊÇ·ñÔÚURLÖаüÀ¨ÓòÃû¡£

¶þ¡¢ÔÚuÒªÁìÖÐת´ï²ÎÊý

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

ÔÚThinkphp3.2.3ÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃÊý×é¡¢×Ö·û´®»ò¹¤¾ßµÈÊý¾ÝÀàÐÍÀ´×ª´ï²ÎÊý¡£ÏÂÃæÎÒÃǽ«»®·ÖÏÈÈÝÔõÑùʹÓÃÕâЩÊý¾ÝÀàÐÍת´ï²ÎÊý¡£

1¡¢Ê¹ÓÃÊý×éת´ï²ÎÊý

ʹÓÃÊý×éת´ï²ÎÊýʱ£¬ÎÒÃÇ¿ÉÒÔ½«²ÎÊý×÷Ϊ¹ØÁªÊý×éת´ï¸øuÒªÁì¡£ÀýÈ磺

$params = array(
    'id' => 1,
    'name' => 'Tom'
);
$url = u('user/detail', $params);

µÇ¼ºó¸´ÖÆ

ÉÏÃæµÄ´úÂëÖУ¬$paramsÊÇÒ»¸ö¹ØÁªÊý×飬°üÀ¨Á½¸ö¼üÖµ¶Ô¡£ÎÒÃǽ«$params×÷Ϊ²ÎÊýת´ï¸øuÒªÁ죬ÌìÉúÒ»¸öURL·¾¶¡£ÔÚ¿ØÖÆÆ÷µÄ²Ù×÷ÒªÁìÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃ$_GET³¬È«¾ÖÊý×éÀ´»ñÈ¡ÕâЩ²ÎÊý£¬ÈçÏ£º

class UserController extends Controller{
    public function detail(){
        $id = $_GET['id'];
        $name = $_GET['name'];
        // do something
    }
}

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

2¡¢Ê¹ÓÃ×Ö·û¹´×ª´ï²ÎÊý

ʹÓÃ×Ö·û¹´×ª´ï²ÎÊýʱ£¬ÎÒÃÇ¿ÉÒÔ½«²ÎÊýÖ±½ÓÆ´½ÓÔÚURL·¾¶ÖУ¬ÀýÈ磺

$url = u('user/detail', 'id=1&name=Tom');

µÇ¼ºó¸´ÖÆ

ÔÚ¿ØÖÆÆ÷µÄ²Ù×÷ÒªÁìÖУ¬ÎÒÃÇ¿ÉÒÔʹÓÃparse_strº¯ÊýÀ´½«²ÎÊýÆÊÎöΪÊý×飬ÈçÏ£º

class UserController extends Controller{
    public function detail(){
        parse_str($_SERVER['QUERY_STRING'], $params);
        $id = $params['id'];
        $name = $params['name'];
        // do something
    }
}

µÇ¼ºó¸´ÖÆ

3¡¢Ê¹Óù¤¾ßת´ï²ÎÊý

ʹÓù¤¾ßת´ï²ÎÊýʱ£¬ÎÒÃÇ¿ÉÒÔ½«²ÎÊý×÷Ϊ¹¤¾ßµÄÊôÐÔת´ï¸øuÒªÁì¡£ÀýÈ磺

class User{
    public $id;
    public $name;
}
$user = new User();
$user->id = 1;
$user->name = 'Tom';
$url = u('user/detail', $user);

µÇ¼ºó¸´ÖÆ

ÔÚ¿ØÖÆÆ÷µÄ²Ù×÷ÒªÁìÖУ¬ÎÒÃÇ¿ÉÒÔʹÓù¤¾ßµÄÊôÐÔÀ´»ñÈ¡ÕâЩ²ÎÊý£¬ÈçÏ£º

class UserController extends Controller{
    public function detail(){
        $id = $_GET['id'];
        $name = $_GET['name'];
        // do something
    }
}

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

Èý¡¢×¢ÖØÊÂÏî

ÔÚʹÓÃuÒªÁìת´ï²ÎÊýʱ£¬ÐèҪעÖØÒÔϼ¸µã£º

1¡¢ÈôÊDzÎÊý°üÀ¨ÌØÊâ×Ö·û£¨Èçб¸Ü£©£¬ÐèҪʹÓÃurlencodeº¯Êý¾ÙÐбàÂë £»

2¡¢ÈôÊDzÎÊýÖаüÀ¨ÖÐÎÄ×Ö·û£¬ÐèҪʹÓÃurlencodeº¯Êý¾ÙÐбàÂ룬»òÕßÔÚuÒªÁìÖÐÉèÖÃ×Ö·û¼¯£¬ÀýÈ磺

$url = u('user/detail', array('name' => 'ÕÅÈý'), '', true, 'utf-8');

µÇ¼ºó¸´ÖÆ

ÔÚ¿ØÖÆÆ÷µÄ²Ù×÷ÒªÁìÖУ¬ÐèҪʹÓÃurldecodeº¯Êý¾ÙÐнâÂ룬ÀýÈ磺

$name = urldecode($_GET['name']);

µÇ¼ºó¸´ÖÆ

3¡¢²ÎÊýµÄת´ï˳Ðò¶ÔURL·¾¶µÄÌìÉúÓÐÓ°Ï죬ÀýÈ磺

$url1 = u('user/detail', 'id=1&name=Tom');
$url2 = u('user/detail', 'name=Tom&id=1');

µÇ¼ºó¸´ÖÆ

$url1ºÍ$url2ÌìÉúµÄURL·¾¶½«·×ÆçÑù¡£

ËÄ¡¢×ܽá

ÒÔÉÏÊÇÔÚThinkphp3.2.3ÖÐʹÓÃuÒªÁìת´ï²ÎÊýµÄÒªÁìºÍ×¢ÖØÊÂÏϣÍû¶Ô¸÷È˵Ŀª·¢ÓÐËù×ÊÖú¡£ÔÚʹÓÃuÒªÁìת´ï²ÎÊýʱ£¬ÐèҪƾ֤ÏÖÕæÏàÐÎÑ¡ÔñÊʺϵIJÎÊýÀàÐÍ£¬²¢×ñÕÕ×¢ÖØÊÂÏî¡£

ÒÔÉϾÍÊÇthinkphp3.2.3 uÒªÁì´«²ÎÊýµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

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

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

QR code
sitemap¡¢ÍøÕ¾µØͼ