Spoofchecker::setAllowedChars
(PHP 8 >= 8.4.0)
Set the set of characters allowed when running checks
Description
Restricts the characters that are considered acceptable by subsequent checks to the set described by pattern. Any character outside of this set causes Spoofchecker::isSuspicious to report a result.
Parameters
patternA character set described as a
UnicodeSetpattern, that is a regular-expression style character class. It must begin with[and end with], for example[a-z0-9].patternOptionsA bitmask controlling how
patternis interpreted. It must be0, orSpoofchecker::IGNORE_SPACEon its own or combined with exactly one ofSpoofchecker::CASE_INSENSITIVE,Spoofchecker::ADD_CASE_MAPPINGS, orSpoofchecker::SIMPLE_CASE_INSENSITIVE.
Return Values
No value is returned.
Errors/Exceptions
Throws a ValueError if pattern is not a valid character set pattern, or if patternOptions is not a valid combination of options.
Examples
Spoofchecker::setAllowedChars example
<?php
$checker = new Spoofchecker();
$checker->setAllowedChars('[a-z0-9]');
var_dump($checker->isSuspicious('hello'));
var_dump($checker->isSuspicious('héllo'));
?>The above example will output:
bool(false)
bool(true)See Also
Spoofchecker::setAllowedLocalesSpoofchecker::isSuspicious