Which of the following experts helped me look at what this function means?

Source: Internet
Author: User
Who will help me see what this function means? PHPcodefunctiondelFileUnderDir ($ dirName) {if ($ handleopendir (& quot; $ dirName & quot;) {while (false! ($ Itemreaddir ($ handle) {if anyone can help me see what this function means
PHP code
  Function delFileUnderDir ($ dirName) {if ($ handle = opendir ("$ dirName") {while (false! ==( $ Item = readdir ($ handle) {// if ($ item! = "." & $ Item! = ".. ") {If (is_dir (" $ dirName/$ item ") {delFileUnderDir (" $ dirName/$ item ");} else {if (unlink ("$ dirName/$ item") echo "successfully deleted the file: $ dirName/$ item
\ N ";}} closedir ($ handle );}}

False! = ($ Item = readdir ($ handle) what does it mean and call a recursive function? I don't really understand it !!

------ Solution --------------------
Delete a file in a folder.
If readdir () is successful, the file name is returned, or FALSE is returned if a failure occurs.
Failure means that opendir () has an error. the directory does not exist or cannot be read.

False! ==( $ Item = readdir ($ handle ))
That is to say, if the file information in the directory is successfully read.

In fact, the glob () function makes this function easier to use.
------ Solution --------------------
Opendir, readdir, standard unix c interface.

This function recursively deletes all common files in a directory and subdirectory.

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.