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

thinkphpÔõÑù»á¼ûÍøÒ³

thinkphpÊÇÒ»¿î»ùÓÚphpÓïÑԵĿªÔ´¿ò¼Ü£¬ËüµÄÉè¼ÆÄ¿µÄÊÇΪÁËÉÁ¿ª·¢ÕßÄܹ»Ô½·¢¸ßЧµØ¿ª·¢webÓ¦ÓóÌÐò¡£ÔÚwebÓ¦ÓóÌÐò¿ª·¢Àú³ÌÖУ¬»á¼ûÍøÒ³ÊÇÒ»¸öºÜÊÇÖ÷ÒªµÄ»·½Ú£¬Òò´ËÔÚ±¾ÎÄÖУ¬ÎÒÃǽ«Ì½ÌÖÔõÑùʹÓÃthinkphp»á¼ûÍøÒ³¡£

Ê×ÏÈ£¬ÎÒÃÇÐèÒªÏàʶThinkPHPÖеÄ·ÓÉ»úÖÆ¡£Â·ÓɾÍÊǽ«URLÓ³Éäµ½¶ÔÓ¦µÄ¿ØÖÆÆ÷ºÍÒªÁ죬Òò´ËÔÚ»á¼ûÍøҳʱ£¬ÐèÒªÏÈÉèÖ÷ÓɹæÔò¡£ÔÚThinkPHPÖУ¬¿ÉÒÔͨ¹ýÔÚapplication\route.phpÎļþÖÐÉèÖ÷ÓɹæÔò¡£ÀýÈ磬ÎÒÃÇ¿ÉÒÔÉèÖÃÒÔÏ·ÓɹæÔò£º

<?php use think\Route;

Route::get('/', 'index/index');
Route::get('about', 'index/about');
Route::get('news/:id', 'index/news')->pattern(['id' =&gt; '\d+']);
?&gt;

µÇ¼ºó¸´ÖÆ

ÉÏÊö·ÓɹæÔòÖУ¬µÚÒ»Ìõ¹æÔòÌåÏÖ»á¼û¸ùĿ¼ʱ£¬½«ÇëÇóת·¢µ½Index¿ØÖÆÆ÷µÄindexÒªÁ죻µÚ¶þÌõ¹æÔòÌåÏÖ»á¼ûaboutÒ³Ãæʱ£¬½«ÇëÇóת·¢µ½Index¿ØÖÆÆ÷µÄaboutÒªÁ죻µÚÈýÌõ¹æÔòÌåÏÖ»á¼ûnewsÒ³Ãæʱ£¬½«ÇëÇóת·¢µ½Index¿ØÖÆÆ÷µÄnewsÒªÁ죬²¢½«URLÖеÄid²ÎÊýת´ï¸ø¸ÃÒªÁì¡£

ÔÚÉèÖú÷ÓɹæÔòÖ®ºó£¬ÎÒÃǾͿÉÒÔͨ¹ýURL»á¼ûÍøÒ³ÁË¡£ÀýÈ磬¹ØÓÚÉÏÊö·ÓɹæÔòÖеĵÚÒ»¸ö¹æÔò£¬ÎÒÃÇ¿ÉÒÔͨ¹ý»á¼ûhttp://localhost/À´»á¼ûÍøÒ³¡£

±ðµÄ£¬ÔÚThinkPHPÖУ¬»¹¿ÉÒÔʹÓÃURLº¯ÊýÌìÉú´øÓзÓɹæÔòµÄURL¡£ÀýÈ磬ʹÓÃÒÔÏ´úÂë¿ÉÒÔÌìÉú»á¼ûaboutÒ³ÃæµÄURL£º

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

<?php $url = url('index/about');
echo $url;
?>

µÇ¼ºó¸´ÖÆ

ÌìÉúµÄURLΪhttp://localhost/about¡£

ÔÚ¾ÙÐÐÍøÒ³»á¼ûʱ£¬»¹ÐèҪעÖØÇå¾²ÐÔ¡£Í¨³£ÇéÐÎÏ£¬Óû§×ª´ïµÄ²ÎÊý¿ÉÄܱ£´æ¶ñÒâ´úÂëµÈÇå¾²Òþ»¼£¬Òò´ËÐèÒª¶Ôת´ïµÄ²ÎÊý¾ÙÐйýÂ˺ÍÑéÖ¤¡£ÔÚThinkPHPÖУ¬¿ÉÒÔʹÓÃinputº¯ÊýÎüÊÕÓû§×ª´ïµÄ²ÎÊý£¬²¢¿ÉÒÔʹÓÃvalidateº¯Êý¶Ô²ÎÊý¾ÙÐÐÑéÖ¤¡£

ÀýÈ磬ʹÓÃÒÔÏ´úÂë¿ÉÒÔÎüÊÕÓû§×ª´ïµÄid²ÎÊý£¬²¢Ê¹ÓÃvalidateº¯ÊýÑéÖ¤¸Ã²ÎÊýÊÇ·ñΪÊý×Ö£º

<?php $id = input('id');
validate(['id'=>'number'])-&gt;check(['id'=&gt;$id]);
?&gt;

µÇ¼ºó¸´ÖÆ

ÈôÊÇÑé֤ʧ°Ü£¬validateº¯Êý½«Å׳öÒ»¸öValidateExceptionÒì³££¬¿ÉÒÔͨ¹ý²¶»ñ¸ÃÒì³£´¦Àí¹ýʧ¡£

×ÛÉÏËùÊö£¬»á¼ûÍøÒ³ÊÇWebÓ¦ÓóÌÐò¿ª·¢µÄÖ÷Òª»·½ÚÖ®Ò»¡£ÔÚʹÓÃThinkPHP¾ÙÐÐÍøÒ³»á¼ûʱ£¬ÐèÒªÉèÖ÷ÓɹæÔò¡¢Ê¹ÓÃURLº¯ÊýÌìÉúURL£¬²¢×¢ÖØÊý¾ÝÇå¾²ÐÔ¡£Ï£Íû±¾ÎÄÄܹ»¶Ô¸÷ÈËÓÐËù×ÊÖú¡£

ÒÔÉϾÍÊÇthinkphpÔõÑù»á¼ûÍøÒ³µÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

QR code
ÍøÕ¾µØͼ