Why are the codes of the two readdir loops different?

Source: Internet
Author: User
Why are the codes of the two readdir loops different? You can only obtain part of the file in the previous section.
$ Han2 = opendir ('dir ');
While (readdir ($ han2 )! = False ){
Echo readdir ($ han2 );
Echo"
";
}
Closedir ($ han2 );

This section can retrieve all files
$ Od = opendir ('dir ');
While ($ readd = readdir ($ od ))! = False ){
Echo $ readd;
Echo"
";
}
Closedir ($ od );


Reply to discussion (solution)

Readdir returns the file name of the next file in the directory.
Your first code uses only half of the results.

Dir contains three files, a B c. Previous paragraph while (readdir ($ han2 )! = False) after running, the cursor will only be moved to the end of a. when running echo readdir ($ han2), you will only read to B. This problem can be completely avoided when the following section is received with variables.

Readdir returns the file name of the next file in the directory.
Your first code uses only half of the results.


I would like to explain why the current directory (.) and the output of the upper-level Directory (..) are displayed when the page is output (..)
Which of the following functions does readdir provide?

Dir contains three files, a B c. Previous paragraph while (readdir ($ han2 )! = False) after running, the cursor will only be moved to the end of a. when running echo readdir ($ han2), you will only read to B. This problem can be completely avoided when the following section is received with variables.

Thank you.

And... are also Directory items, of course, will be displayed
If not, you have to judge.


Readdir returns the file name of the next file in the directory.
Your first code uses only half of the results.


I would like to explain why the current directory (.) and the output of the upper-level Directory (..) are displayed when the page is output (..)
Which of the following functions does readdir provide?

It was intentionally designed in the PHP Kernel. it may be called the readdir function of C, and the readdir function of C also reads.

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.