日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

dir函数_PHP dir()函数与示例

發布時間:2025/3/11 php 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 dir函数_PHP dir()函数与示例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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()函数与示例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。