zoukankan      html  css  js  c++  java
  • PHP opendir() 函数

    ------------恢复内容开始------------

    实例

    打开一个目录,读取它的内容,然后关闭:

    <?php
    $dir = "/images/";

    // Open a directory, and read its contents
    if (is_dir($dir)){
    if ($dh = opendir($dir)){
    while (($file = readdir($dh)) !== false){
    echo "filename:" . $file . "<br>";
    }
    closedir($dh);
    }
    }
    ?>

    结果:

    filename: cat.gif
    filename: dog.gif
    filename: horse.gif

    定义和用法

    opendir() 函数打开目录句柄。


    语法

    opendir(path,context);
    参数描述
    path 必需。规定要打开的目录路径。
    context 可选。规定目录句柄的环境。context 是可修改目录流的行为的一套选项。

    技术细节

    返回值: 成功则返回目录句柄资源。失败则返回 FALSE。如果路径不是合法目录,或者由于许可限制或文件系统错误导致的目录不能打开,则抛出 E_WARNING 级别的错误。您可以通过在函数名称前添加 '@' 来隐藏 opendir() 的错误输出。
    PHP 版本: 4.0+高佣联盟 www.cgewang.com
    PHP 更新日志: PHP 5.0:path 参数支持 ftp:// URL 封装协议。

    ------------恢复内容结束------------

  • 相关阅读:
    设计模式-观察者模式
    ps一寸照的编辑
    ps剪切蒙版的使用
    ps扣头发
    mysql索引优化
    ES6 $ ES5
    sping-mybatis集成
    多线程--volatile
    eclipse.exe打开是报错
    Spring Aop 详解二
  • 原文地址:https://www.cnblogs.com/yc10086/p/12993194.html
Copyright © 2011-2022 走看看