(PHP 4 >= 4.3.0, PHP 5, PHP 7)
fnmatch — 锟斤拷模式匹锟斤拷锟侥硷拷锟斤拷
$pattern
, string $string
[, int $flags
= 0
] ) : bool
fnmatch()
锟斤拷榇拷锟斤拷
string
锟角凤拷匹锟斤拷锟斤拷锟斤拷锟� shell 统锟斤拷锟�
pattern
锟斤拷
pattern
shell 统锟斤拷锟斤拷锟�
string
要锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷 锟剿猴拷锟斤拷锟斤拷锟斤拷锟侥硷拷锟斤拷锟斤拷锟斤拷锟斤拷锟矫o拷锟斤拷也锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷通锟斤拷锟街凤拷锟斤拷锟斤拷
锟斤拷通锟矫伙拷锟斤拷锟斤拷习锟斤拷锟斤拷 shell 模式锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷虻サ锟斤拷锟绞� '?' 锟斤拷 '*' 通锟斤拷锟斤拷锟斤拷锟斤拷使锟斤拷 fnmatch() 锟斤拷锟斤拷锟斤拷 preg_match() 锟斤拷锟斤拷锟斤拷前锟斤拷锟斤拷锟斤拷锟斤拷锟绞斤拷锟斤拷锟斤拷锟节非筹拷锟斤拷员锟矫伙拷锟斤拷锟接凤拷锟姐。
flags
The value of flags
can be any combination of
the following flags, joined with the
binary OR (|) operator.
Flag |
Description |
---|---|
FNM_NOESCAPE |
Disable backslash escaping. |
FNM_PATHNAME |
Slash in string only matches slash in the given pattern. |
FNM_PERIOD |
Leading period in string must be exactly matched by period in the given pattern. |
FNM_CASEFOLD |
Caseless match. Part of the GNU extension. |
匹锟斤拷锟津返伙拷 TRUE
锟斤拷锟斤拷锟津返伙拷 FALSE
锟斤拷
锟芥本 | 说锟斤拷 |
---|---|
5.3.0 | 锟剿猴拷锟斤拷锟斤拷始锟斤拷 Windows 平台锟斤拷锟斤拷效锟斤拷 |
Example #1 锟斤拷 shell 锟叫碉拷通锟斤拷锟侥J狡ワ拷锟斤拷锟斤拷锟斤拷锟斤拷色锟斤拷锟斤拷
<?php
if (fnmatch("*gr[ae]y", $color)) {
echo "some form of gray ...";
}
?>
目前锟矫猴拷锟斤拷锟睫凤拷锟斤拷 Windows 锟斤拷锟斤拷锟斤拷锟斤拷 POSIX 锟斤拷锟捷碉拷系统锟斤拷使锟矫★拷