dir函数

PHP dir()函数 (PHP dir() function)

dir() function is an instance of the directory class, it is used to read the directory, it includes handle and path properties – which can be used to get the resource id and path to the directory. Both handle and path have read(), rewind(), and close() methods.

dir()函数是目录类的实例,用于读取目录,它包括句柄和路径属性–可用于获取资源ID和目录的路径。 句柄和路径都具有read() , rewind()和close()方法。

Syntax:

句法:

    dir(directory,context);

Parameter(s):

参数:

  • directory – It is used to specify the path to the directory to be opened.

    directory –用于指定要打开的目录的路径。

  • context – It is an optional parameter; it defines the context (a set of options that can modify the behavior of the stream).

    上下文 –它是一个可选参数; 它定义了上下文(一组可以修改流行为的选项)。

Return value:

返回值:

On success – it returns an instance to the directory, on fail – it returns "FALSE".

成功–将实例返回目录;失败–将返回“ FALSE”。

Example: PHP code to demonstrate example of dir() function

示例:PHP代码演示dir()函数的示例

<?php
//path to current working directory
$cwd = dir(getcwd());
echo "Directory handle: " . $cwd->handle . "<br>";
echo "Current path: " . $cwd->path . "<br>";
//reading & printing the filenames using dir()
while (($file = $cwd->read()) !== false){
echo "File: " . $file . "<br>";
}
//closing the dir instance
$cwd->close();
?>

Output

输出量

Directory handle: Resource id #5
Current path: /home
File: .
File: ..
File: main.php

Reference: PHP dir() function

参考: PHP dir()函数

翻译自: https://www.includehelp.com/php/dir-function-with-example.aspx

dir函数

dir函数_PHP dir()函数与示例相关推荐

  1. java回调函数_PHP回调函数及匿名函数概念与用法详解

    1.回调函数 PHP的回调函数其实和C.Java等语言的回调函数的作用是一模一样的,都是在主线程执行的过程中,突然跳去执行设置的回调函数: 回调函数执行完毕之后,再回到主线程处理接下来的流程 而在ph ...

  2. php rename函数_php rename函数怎么用

    PHP rename()函数用于重命名文件或目录,语法"rename(文件旧名称,新名称,句柄环境)",使用用户指定的新名称更改文件或目录的旧名称,并且可以根据需要在目录之间移动: ...

  3. php rename函数_PHP rename函数使用详解(php重命名文件)

    PHP中的rename()函数是一个内置函数,用于重命名文件或目录.它尝试用用户指定的新名称更改文件或目录的旧名称,并且在必要时可以在目录之间移动. 如果用户指定的新名称已经存在,rename()函数 ...

  4. mysql_assoc函数_PHP:MySQL函数mysql_fetch_assoc()的用法

    mysql_fetch_assoc (PHP 4 >= 4.0.3, PHP 5) mysql_fetch_assoc - 从结果集中取得一行作为关联数组 Warning 本扩展自 PHP 5. ...

  5. php 危险函数_PHP 危险函数有哪些?

    在编译 PHP 时,如无特殊需要,一定禁止编译生成 CLI 命令行模式的 PHP 解析支持.可在编译时使用 –disable-CLI.一旦编译生成 CLI 模式的PHP,则可能会被入侵者利用该程序建立 ...

  6. mysql addslashes()函数_PHP addslashes 函数

    一.函数功能: 数据库查询语句的要求,在单引号(').双引号(").反斜线(\)与 NUL(NULL 字符) 等特殊字符前添加反斜杠.它是stripslashes()函数的反向操作函数. 二 ...

  7. mysql rollback函数_PHP mysqli_rollback() 函数_程序员人生

    实例 关闭自动提交,做一些查询,提交查询,然后回滚当前事务: $con=mysqli_connect("localhost","my_user","m ...

  8. php mail函数_php 发送邮件函数

    /** * 记录数据 */ function runlog($mode = 'SMTP',$b = '',$c = '',$d='') { } /** * 发送邮件 * @param $toemail ...

  9. dir函数python_Python dir()函数

    dir函数python Python dir() function attempts to return a list of valid attributes for the given object ...

最新文章

  1. OpenGL学习总结
  2. “面试不败计划”:面试题基础二
  3. iOS Sharing #02 | 2019-03-30
  4. c语言实战1200例 pdf6,C语言程序设计6.6.2.pdf
  5. 网易云 IM SDK 4.2.0版本逆袭升级!
  6. C语言高级编程:二维数组、指针的指针、数组指针、指针数组
  7. 微服务为什么选Spring Cloud
  8. A10 平板开发一硬件平台搭建
  9. 修改linux最大文件句柄数
  10. 计算机基础(五):堆和栈区别
  11. linux 基础练习题、面试题(二)
  12. Java中this关键字详解
  13. 红米6pro刷Android原生,红米6 Pro 魔趣OS 安卓9 MagiskV21版 完美ROOT 纯净完美 原生极简 纯净推荐...
  14. 体验极好的临时邮箱,10分钟邮箱,极美观,速度特别快
  15. 美国区块链与药品供应链管理的应用案例
  16. 小米air2se耳机只有一边有声音怎么办_这不是一款首饰盒,但它是最好的情人节礼物,小米TWS耳机Air2SE...
  17. 银行业务系统(c/s架构、socket网络编程、多线程)
  18. java技术面试总结评语,成长路线图
  19. 风华贴片电容命名规则
  20. Flutter 保护你的APP数据安全

热门文章

  1. java技术教程视频_Spring开发视频教程高级篇+源码(400M)33讲
  2. Python二级笔记(13)
  3. MySQL(6)视图
  4. python几何拼贴画_图形几何图形拼贴画
  5. python选择题题库百度文库_大学Python程序题题库
  6. 【SpringBoot 2】(八)数据响应 页面响应
  7. Pytorch RuntimeERROR: Given groups=1 weights of size [256,64,1,1] expected input[1,16,256,256] to
  8. Deepin安装最新显卡RTX2080Ti及CUDA10.1
  9. Problem D: 编程题B-向量的数量积
  10. GO编程程序员修炼秘籍:十本经典书单