摘要
fnmatch() 函数用于在指定字符串中匹配通配符模式。该函数以区分大小写的方式将字符串与模式进行比较,并返回布尔值表示匹配成功与否。
详细说明
语法
bool fnmatch(string $pattern, string $string, int $flags = 0)
参数
通配符
fnmatch() 函数支持以下通配符:
匹配行为
fnmatch() 函数的匹配行为受 $flags 参数中指定标志的影响:
返回值
fnmatch() 函数返回一个布尔值:
示例
示例 1:简单匹配
$pattern = "*.txt";
$string = "file1.txt";
$result = fnmatch($pattern, $string); // TRUE
示例 2:使用通配符
$pattern = "ab*";
$string = "abcdef";
$result = fnmatch($pattern, $string); // TRUE
示例 3:使用标志
$pattern = "*.txt";
$string = "FILE1.TXT";
$result = fnmatch($pattern, $string, FNM_CASEFOLD); // TRUE
注意
以上就是PHP中 fnmatch() 函数什么意思?有什么作用?的详细内容,更多请关注编程网其它相关文章!
--结束END--
本文标题: PHP中 fnmatch() 函数什么意思?有什么作用?
本文链接: https://www.lsjlt.com/wiki/db0bac0b22.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0