尊龙凯时人生就是搏

ThinkPHP5ÖÐÔõôŲÓÃÒªÁì

Ò»¡¢¿ØÖÆÆ÷ÖеÄÒªÁìŲÓÃ

¿ØÖÆÆ÷ÊÇÓ¦ÓóÌÐòÖд¦ÀíHTTPÇëÇó²¢Ïòä¯ÀÀÆ÷·¢ËÍÏìÓ¦µÄµØ·½¡£ThinkPHP5ÖеĿØÖÆÆ÷Ö÷ҪλÓÚappĿ¼Ï £¬¿ØÖÆÆ÷µÄÃüÃû¹æÔòÊÇÒÔÍÕ·åʽÃüÃû·¨ £¬ÀýÈ磺UserController.php¡£ÔÚ¿ØÖÆÆ÷ÖÐ £¬ÎÒÃÇ¿ÉÒÔ½ç˵¶à¸öÒªÁìÀ´ÏìÓ¦²î±ðµÄÇëÇó¡£ÍÕ·åʽÃüÃû·¨Ó¦¸ÃÊÊÓÃÓÚÒªÁìÃû³Æ £¬È磺indexAction()¡£

ҪŲÓÿØÖÆÆ÷ÖеÄÒªÁì £¬ÐèҪͨ¹ýURLÀ´»á¼û¡£URLÖеÄÓòÃûºÍ¶Ë¿ÚºÅºóÃæ½ôËæ×ŵÄÊÇ¿ØÖÆÆ÷µÄÃû³Æ £¬ÀýÈ磺http://example.com/UserController¡£¶ø»á¼û¿ØÖÆÆ÷ÖеÄÒªÁì £¬ÔòÐèÒªÔÚURLºóÃæÌí¼ÓÒªÁìÃû³Æ £¬ÀýÈ磺http://example.com/UserController/index¡£

ÎÒÃÇ¿ÉÒÔÔÚ¿ØÖÆÆ÷ÒªÁìÖÐʹÓÃÄÚÖú¯ÊýÀ´»ñÈ¡HTTPÇëÇó²ÎÊý¡¢»á¼ûÊý¾Ý¿â¡¢Êä³öÄ£°åµÈ¡£ÀýÈç £¬ÏÂÃæµÄ´úÂëÑÝʾÁËÔõÑù»ñÈ¡HTTPÇëÇóÖеIJÎÊý£º

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

public function index()
{
    $name = $this->request->param('name');
    $age = $this->request->param('age');
    echo "ÐÕÃû£º".$name."<br>ÄêË꣺".$age;
}

µÇ¼ºó¸´ÖÆ

¶þ¡¢Ä£×ÓÖеÄÒªÁìŲÓÃ

Ä£×ÓÊÇÓ¦ÓóÌÐòÖÐÈÏÕæÖÎÀíÊý¾ÝµÄµØ·½¡£ThinkPHP5ÖеÄÄ£×ÓλÓÚappĿ¼ÏµÄmodelĿ¼ÖÐ £¬Ä£×ÓµÄÃüÃû¹æÔòÊÇÒÔÍÕ·åʽÃüÃû·¨ £¬ÀýÈ磺UserModel.php¡£

ÔÚÄ£×ÓÖÐ £¬ÎÒÃÇ¿ÉÒÔ½ç˵¶à¸öÒªÁìÀ´ÖÎÀíÊý¾Ý¡£ÒªÁìÃû³ÆӦʹÓÃÍÕ·åʽÃüÃû·¨ £¬ÀýÈ磺getUserInfo()¡£

ÔÚ¿ØÖÆÆ÷ÖÐʵÀý»¯Ä£×Ó £¬ÒÔ´ËÀ´Å²ÓÃÄ£×ÓÖеÄÒªÁì¡£ÀýÈç £¬ÏÂÃæµÄ´úÂëÑÝʾÁËÔõÑùÔÚ¿ØÖÆÆ÷ÖÐŲÓÃÄ£×ÓÖеÄÒªÁ죺

public function index()
{
    $userModel = new \app\model\UserModel();
    $userInfo = $userModel->getUserInfo(1);
    echo "ÐÕÃû£º".$userInfo['name']."<br>ÄêË꣺".$userInfo['age'];
}

µÇ¼ºó¸´ÖÆ

Èý¡¢ÊÓͼÖеÄÒªÁìŲÓÃ

ÊÓͼÊÇÓ¦ÓóÌÐòÖÐÈÏÕæչʾÊý¾ÝµÄµØ·½¡£ThinkPHP5ÖеÄÊÓͼλÓÚappĿ¼ÏµÄviewĿ¼ÖÐ £¬ÊÓͼµÄÃüÃû¹æÔòÊÇÒÔÍÕ·åʽÃüÃû·¨ £¬²¢ÇÒÒÔ.tplΪºó׺Ãû £¬ÀýÈ磺userList.tpl¡£

ÔÚÊÓͼÖÐ £¬ÎÒÃÇ¿ÉÒÔʹÓÃÄÚÖú¯Êý»ò×Ô½ç˵º¯ÊýÀ´Õ¹Ê¾Êý¾Ý¡£ÏÂÃæµÄ´úÂëʾÀýչʾÁËÔõÑùÔÚÊÓͼÖÐŲÓÃÄÚÖú¯ÊýechoÊä³öÊý¾Ý£º

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Óû§Áбí</title>
</head>
<body>
    <table>
        <tr>
            <th>񅧏</th>
            <th>ÐÕÃû</th>
            <th>ÄêËê</th>
        </tr>
        <?php foreach($userList as $user) { ?>
        <tr>
            <td><?php echo $user['id']; ?></td>
            <td><?php echo $user['name']; ?></td>
            <td><?php echo $user['age']; ?></td>
        </tr>
        <?php } ?>
    </table>
</body>
</html>

µÇ¼ºó¸´ÖÆ

ÒÔÉϾÍÊÇThinkPHP5ÖÐÔõôŲÓÃÒªÁìµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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