語法
| int glob(const char *pattern, int flags, int errfunc(const char *epath, int eerrno), glob_t *pglob); |
注釋:GLOB_ERR 是 PHP 5.1 添加的。
| 參數 | 描述 |
| file | 必需。規定檢索模式。 |
| size | 可選。規定特殊的設定。 |
| GLOB_MARK - 在每個返回的項目中加一個斜線 | |
| GLOB_NOSORT - 按照檔案在目錄中出現的原始順序返回(不排序) | |
| GLOB_NOCHECK - 如果沒有檔案匹配則返回用於搜尋的模式 | |
| GLOB_NOESCAPE - 反斜線不轉義元字元 | |
| GLOB_BRACE - 擴充 {a,b,c} 來匹配 'a','b' 或 'c' | |
| GLOB_ONLYDIR - 僅返回與模式匹配的目錄項 | |
| GLOB_ERR - 停止並讀取錯誤信息(比如說不可讀的目錄),默認的情況下忽略所有錯誤 |
例子 1
| <?php print_r(glob("*.txt")); ?> |
輸出類似:
| Array ( [0] => target.txt [1] => source.txt [2] => test.txt [3] => test2.txt ) |
例子 2
| <?php print_r(glob("*.*")); ?> |
輸出類似:
| Array ( [0] => contacts.csv [1] => default.php [2] => target.txt [3] => source.txt [4] => tem1.tmp [5] => test.htm [6] => test.ini [7] => test.php [8] => test.txt [9] => test2.txt ) |
PHP Filesystem 函式

