PHP glob()找不到.htaccess [英] PHP glob() doesnt find .htaccess

查看:81
本文介绍了PHP glob()找不到.htaccess的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个简单的问题-如何使用 glob()列出 .htaccess 个文件?

Simple question - How to list .htaccess files using glob()?

推荐答案

glob() 确实列出隐藏文件(以开头的文件。包括目录 .. ),但只有在您明确要求以下条件时:

glob() does list "hidden" files (files starting with . including the directories . and ..), but only if you explicitly ask it for:

 glob(".*");

过滤返回的 glob()数组带有 preg_grep .htaccess 条目c>

Filtering the returned glob() array for .htaccess entries with preg_grep:

 $files = glob(".*") AND $files = preg_grep('/\.htaccess$/', $files);

当然,替代glob的方法只是使用 scandir() 和一个过滤器( fnmatch 或正则表达式):

The alternative to glob of course would be just using scandir() and a filter (fnmatch or regex):

 preg_grep('/^\.\w+/', scandir("."))

这篇关于PHP glob()找不到.htaccess的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆