A case study of Dynamic Web technology PHP development file system

Source: Internet
Author: User

Focus on the application of file functions in PHP

PHP has many file system-related functions that not only open files, but also display content, move files, and other features in the directory, and many people even use PHP to develop internet-based file Explorer.

The following script sample can display a list of directories that are already included in the code:

? / the full path name of the directory to be read into a variable named $dir_name. /
$dir _name = "/home/me/";
/ creates a handle whose value is the result of opening a given directory /
$dir = Opendir ($dir _name);
/ creates a block of text to place the list element (file name) /
$file _list = "

    ";
    / uses a while statement to read all the elements in a directory that is already open, if the file name is not "." or "..", the name in the list is displayed/
    while ($file _name = Readdir ($dir)) {
    if ($file _name!= ".") &&&& ($file _name!= "...")) {
    $file _list. = "
  • $file _name";
    }
    }
    $file _list. = "
";
/ closes the Open Directory and ends the PHP module /
Closedir ($dir);
? >
!--Start your HTML-->


Directory Listing


!--use PHP to print the name of this directory you read-->

Files in:? echo "$dir _name";? >


!--use PHP to print the directory listing-->
? echo "$file _list";



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.