search
Homephp教程php手册php代码:实现当前目录文件列表列出

php代码:实现当前目录文件列表列出

Jun 13, 2016 am 11:38 AM
phpcodeaboutlistlistcollegeaccomplishBuild a websitedocumentTable of contentsnetwork programming

  烈火建站学院(Bkjia.Com)网络编程 关于php实现列出当前文件列表的方法,网上有很多,近日bkjia.com的小编综合了网上的一些资料, 改写了一下,感觉这是最佳的方法,特别将代码公布出来。

以下为引用的内容:

function tree($directory)
{
echo date(”Y-m-d H:i:s”);
$i=0;
$mydir=dir($directory);
echo “

    \n”;
    while($file=$mydir->read() AND $i{
    if((is_dir(”$directory”)) AND ($file!=”.”) AND ($file!=”..”))
    {
    $filetime=date(”Y-m-d H:i:s”,filectime($file));
    //encode spaces
    $file =  rawurlencode($file);
    // convert the + (this is one result from the function rawurlencode) in %20
    $url = str_replace(’+’ , ‘%20′ , $file);
    echo “
  • ”.$url.”  $filetime
  • \n”;
    $i+=1;
    }
    }
    echo “
\n”;
$mydir->close();
}

tree(”.”);  // 列出当前目录
?>

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)