PHP之readdir()函数,phpreaddir函数
最近在学习php文件操作的相关知识,记录一下readdir()函数其中的一个要注意的点
1、 在$temp=readdir($handle)函数中 readdir获取的是文件名和$handle中的文件夹名,
一般在程序中遍历文件通过while()循环:
while($temp=readdir($handel)){}
但是这种写法的判断语句存在一个问题就是:如果$handle下面有个文件夹的名字为'0',那么$temp=0,while循环就无法进行下去,那么就无法遍历其余的文件,导致程序结果不对,
正确的写法:
while(($temp=readdir($handel))!==false){}//用不全等于是区分如果文件夹名字为0的时候,那么0!==false,仍然可以遍历

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Mac version
God-level code editing software (SublimeText3)

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

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.

Zend Studio 13.0.1
Powerful PHP integrated development environment
