php获取网页内容的几种方法
PHP实现的文件浏览器功能简单示例本文实例讲述了PHP实现的文件浏览器功能。分享给大家供大家参考,具体如下:
|
<?php if (isset( $_GET [ 'path' ])){ echo $path = $_SERVER [ 'DOCUMENT_ROOT' ]. $_GET [ 'path' ]; $pre_path = $_GET [ 'path' ]; } else { echo $path = $_SERVER [ 'DOCUMENT_ROOT' ]; $pre_path = "" ; } ?> <html> <head> <title></title> <meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" /> </head> <body> <table border= "1" > <thead> <tr> <td>文件名</td> <td>文件大小</td> <td>文件类型</td> <td>修改时间</td> </tr> <thead> <tbody> <?php $url_this = "http://" . $_SERVER [ 'HTTP_HOST' ]. $_SERVER [ 'PHP_SELF' ]; $handle = opendir( $path ); while ( $file =readdir( $handle )){ echo "<tr>" ; echo "<td>" . $file . "</td>" ; echo "<td>" . filesize ( $path . "/" . $file ). "</td>" ; if ( filetype ( $path . "/" . $file )== "dir" ){ $next = $pre_path . "/" . $file ; echo "<td><a href=\"$url_this?path=$next\">dir</a></td>" ; } else { echo "<td>" . filetype ( $path . "/" . $file ). "</td>" ; } echo "<td>" . date ( "Y年n月t日" , filemtime ( $path . "/" . $file )). "</td>" ; echo "</tr>" ; } closedir ( $handle ); ?> </tbody> </table> </body> </body> |
希望本文所述对大家PHP程序设计有所帮助。
原文链接:https://blog.csdn.net/koastal/article/details/50274087