fnmatch
Function • Params and return types changed in PHP 8.0
Match filename against a pattern.
fnmatch Function synopsis
fnmatch(
string $pattern,
string $filename,
int $flags = 0
): bool
Parameters
$pattern
Typestring
The $pattern to match against. Usually, the $pattern will contain
wildcards like '?' and '*'.
$filename
Typestring
The tested string. This function is especially useful for filenames, but may also be used on regular strings.
$flags
OptionalTypeintDefault value0
The value of $flags can be any combination of
the following flags, joined with the
binary OR (|) operator.
$flags accepts one or a bitmask of the following constant values:
Return value
Typebool
Returns true if there is a match, false otherwise.
Changes to the fnmatch Function
PHP 8.0
- Return type added:
bool - Parameter type added for parameter #1 (
$pattern):string - Parameter type added for parameter #2 (
$filename):string - Parameter type added for parameter #3 (
$flags):int - Parameter default value added for position #3 (
$flags):0
fnmatch(
- $pattern,
+ string $pattern,
- $filename,
+ string $filename,
- $flags
+ int $flags = 0
- )
+ ): bool fnmatch Function Availability
fnmatch Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |