Table of Contents
PHP之readdir()函数,phpreaddir函数
Home php教程 php手册 PHP之readdir()函数,phpreaddir函数

PHP之readdir()函数,phpreaddir函数

Jun 13, 2016 am 08:52 AM
readdir

PHP之readdir()函数,phpreaddir函数

  最近在学习php文件操作的相关知识,记录一下readdir()函数其中的一个要注意的点

          1、 在$temp=readdir($handle)函数中 readdir获取的是文件名和$handle中的文件夹名,

    一般在程序中遍历文件通过while()循环:

         while($temp=readdir($handel)){}
Copy after login

   但是这种写法的判断语句存在一个问题就是:如果$handle下面有个文件夹的名字为'0',那么$temp=0,while循环就无法进行下去,那么就无法遍历其余的文件,导致程序结果不对,

正确的写法:

    while(($temp=readdir($handel))!==false){}//用不全等于是区分如果文件夹名字为0的时候,那么0!==false,仍然可以遍历
Copy after login

      

Statement of this Website
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)