尊龙凯时人生就是博

thinkphpĿ¼»á¼ûʵÏÖ

Ëæ×ÅwebÓ¦ÓõÄÒ»Ö±Éú³¤£¬Ðí¶àwebÓ¦ÓýÓÄÉÁËmvc¿ò¼ÜÀ´¾ÙÐпª·¢£¬¶øthinkphp¿ò¼Ü¾ÍÊÇÆäÖÐÆÄÊܽӴýµÄÒ»¸ö¡£ÔÚthinkphp¿ò¼Ü¿ª·¢Àú³ÌÖУ¬¾­³£ÐèÒª¶ÔÏîÄ¿µÄĿ¼¾ÙÐлá¼û£¬±¾ÎĽ«ÏÈÈÝÔõÑùÔÚthinkphp¿ò¼ÜÖÐʵÏÖĿ¼»á¼û¡£

Ò»¡¢ÐèÇóÆÊÎö

ÔÚ¾ÙÐÐthinkphp¿ò¼Ü¿ª·¢Ê±£¬ÓÐʱ»áÐèÒª¶ÔÏîÄ¿µÄijЩĿ¼¾ÙÐлá¼û£¬ÀýÈçÐèÒª¶ÁÈ¡ÏîÄ¿ÖеÄͼƬ¡¢CSSÎļþµÈ¡£¿ÉÊÇ£¬ÓÉÓÚthinkphp¿ò¼ÜÖÐĬÈϵĻá¼û·½·¨ÊÇͨ¹ýURL»á¼û¿ØÖÆÆ÷ÖеÄÒªÁìÀ´´¦ÀíÇëÇó£¬Òò´ËÐèҪʵÏÖĿ¼»á¼ûµÄ¹¦Ð§¡£

¶þ¡¢ÊµÏּƻ®

thinkphp¿ò¼ÜÖÐÒѾ­ÌṩÁËÏà¹ØµÄº¯ÊýºÍÀ࣬¿ª·¢ÕßÖ»ÐèÒªÉÔ΢ÐÞ¸ÄһϾͿÉÒÔʵÏÖĿ¼»á¼ûµÄ¹¦Ð§¡£ÏêϸʵÏÖ°ì·¨ÈçÏ£º

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

½¨ÉèÒ»¸öеĿØÖÆÆ÷£¬²¢Ìí¼ÓÒ»¸öеÄÒªÁ죬ÓÃÓÚ´¦ÀíĿ¼»á¼ûÇëÇó¡£ÏÂÃæÊÇʾÀý´úÂ룺

class DirController extends Controller{
     public function index(){
          $path=$_GET['path'];//»ñÈ¡Òª»á¼ûµÄĿ¼·¾¶
          $dir=dir($path);//·­¿ªÄ¿Â¼
          $dirs=array();//ÉúÑÄĿ¼Áбí
          while($entry=$dir->read()){
               if($entry!='.' && $entry!='..'){
                    if(is_dir($path.'/'.$entry)){
                         //ÊÇĿ¼
                         $dirs[]=$entry;
                    }
               }
          }
          $this->assign('dirs',$dirs);//°ÑĿ¼Áбíת´ï¸øÄ£°å
          $this->display();//ÏÔʾģ°å
     }
}

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÒªÁìÖУ¬ÎÒÃÇÊ×ÏÈ´Ó$_GETÖлñÈ¡Òª»á¼ûµÄĿ¼·¾¶£¬È»ºóʹÓÃPHP×Ô´øº¯Êýdir()·­¿ªÄ¿Â¼£¬²¢Ê¹ÓÃÑ­»·Óï¾ä±éÀúĿ¼ÖеÄËùÓÐÄÚÈÝ¡£ÈôÊÇij¸öÄÚÈÝÊÇÒ»¸öĿ¼£¬Ôò°ÑĿ¼Ãû³ÆÉúÑĵ½$dirsÊý×éÖУ¬²¢×îÖÕ½«Æäת´ï¸øÄ£°å¡£

½¨ÉèÒ»¸öеÄÄ£°åÎļþ£¬²¢ÏÔʾĿ¼Áбí¡£ÏÂÃæÊÇʾÀý´úÂ룺

<!DOCTYPE html>
<html>
<head>
     <title>Ŀ¼Áбí</title>
</head>
<body>
     <ul>
          <?php foreach($dirs as $dir):?>
               <li><a href='<?php echo "/".$path."/".$dir;?>'><?php echo $dir;?></a></li>
          <?php endforeach;?>
     </ul>
</body>
</html>

µÇ¼ºó¸´ÖÆ

¸ÃÄ£°åÎļþÖУ¬ÎÒÃÇÊ×ÏÈʹÓÃforeachÑ­»·Óï¾ä£¬±éÀú$dirsÊý×éÖеÄËùÓÐĿ¼£¬²¢ÏÔʾµ½Ò³ÃæÉÏ¡£Í¬Ê±£¬ÎÒÃÇ°Ñÿ¸öĿ¼µÄÃû³Æ×÷ΪÁ´½Ó²¢Ìí¼Óµ½< a >±êÇ©ÖУ¬ÒÔ±ãÓû§¿ÉÒÔͨ¹ýµã»÷Á´½Ó½øÈëÌض¨µÄĿ¼¡£

Ð޸ķÓɹæÔò£¬½«URLÖض¨Ïòµ½¿ØÖÆÆ÷µÄĿ¼»á¼ûÒªÁì¡£ÏÂÃæÊÇʾÀý´úÂ룺

'__pattern__' => [
    'path' => '(w+/)*w+'
],
'/:path$' => 'Dir/index',

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸ö·ÓɹæÔòÖУ¬ÎÒÃÇÊ×ÏȽç˵ÁËÒ»¸öͨÅä·ûpattern£¬ÓÃÒÔÆ¥ÅäÏëÒª»á¼ûµÄĿ¼Ãû³Æ¡£È»ºó£¬Æ¾Ö¤Æ¥Åä¹æÔò½«ÇëÇóÖض¨Ïòµ½Dir¿ØÖÆÆ÷µÄindexÒªÁìÖС£

×îºóÒ»²½ÊÇͨ¹ýURL»á¼ûËùÒªµÄĿ¼£¬ÒÔÏÔʾĿ¼Áбí¡£ÀýÈ磬ÏëÒª»á¼ûÏîÄ¿ÖеÄpublic/imagesĿ¼£¬¿ÉÒÔʹÓÃÒÔÏÂURL£º

http://yourdomain.com/images

ÔÚЧÀÍÆ÷¶Ë£¬ÓÉ·ÓɹæÔòÈÏÕ潫ÇëÇóÖض¨Ïòµ½Dir¿ØÖÆÆ÷µÄindexÒªÁ죬²¢ÔÚÒªÁìÖлñȡĿ¼ÁÐ±í²¢×ª´ïµ½Ä£°å¡£×îÖÕ£¬Ä£°å½«Ä¿Â¼ÁбíÏÔʾÔÚÒ³ÃæÉÏ¡£

Èý¡¢×ܽá

ͨ¹ý±¾ÎĵÄÏÈÈÝ£¬ÎÒÃÇÏàʶµ½ÁËÔÚthinkphp¿ò¼ÜÖÐʵÏÖĿ¼»á¼ûµÄ¼Æ»®¡£¸Ã¼Æ»®Ö»ÐèÒªÐÞ¸ÄÉÙÁ¿´úÂ룬¼´¿ÉÀû±ãµØʵÏÖĿ¼»á¼ûµÄ¹¦Ð§£¬Ìá¸ßÁËWebÓ¦ÓõÄÎÞаÐԺͿÉÀ©Õ¹ÐÔ¡£

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

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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