大网数据广告活动
PHP 语言与运行手册

The Spoofchecker class

· 52CE 我爱测

(PHP 5 >= 5.4.0, PHP 7, PHP 8, PECL intl >= 2.0.0)

The Spoofchecker class

(PHP 5 >= 5.4.0, PHP 7, PHP 8, PECL intl >= 2.0.0)

Introduction

This class is provided because Unicode contains large number of characters and incorporates the varied writing systems of the world and their incorrect usage can expose programs or systems to possible security attacks using characters similarity.

Provided methods allow to check whether an individual string is likely an attempt at confusing the reader (spoof detection), such as "pаypаl" spelled with Cyrillic 'а' characters.

Class synopsis

class Spoofchecker {
/* Constants */
public const int ANY_CASE;
public const int SINGLE_SCRIPT;
public const int INVISIBLE;
public const int CHAR_LIMIT;
public const int ASCII;
public const int HIGHLY_RESTRICTIVE;
public const int UNRESTRICTIVE;
public const int MIXED_NUMBERS;
public const int HIDDEN_OVERLAY;
public const int IGNORE_SPACE;
public const int CASE_INSENSITIVE;
public const int ADD_CASE_MAPPINGS;
/* Methods */
public function __construct()
public function areConfusable(string $string1, string $string2, int &$errorCode = null): bool
public function isSuspicious(string $string, int &$errorCode = null): bool
public function setAllowedChars(string $pattern, int $patternOptions = 0): void
public function setAllowedLocales(string $locales): void
public function setChecks(int $checks): void
public function setRestrictionLevel(int $level): void
}

Predefined Constants

Spoofchecker::SINGLE_SCRIPT_CONFUSABLE int

Spoofchecker::MIXED_SCRIPT_CONFUSABLE int

Spoofchecker::WHOLE_SCRIPT_CONFUSABLE int

Spoofchecker::ANY_CASE int

Spoofchecker::SINGLE_SCRIPT int

Spoofchecker::INVISIBLE int

Spoofchecker::CHAR_LIMIT int

Spoofchecker::ASCII int

Spoofchecker::HIGHLY_RESTRICTIVE int

Spoofchecker::MODERATELY_RESTRICTIVE int

Spoofchecker::MINIMALLY_RESTRICTIVE int

Spoofchecker::UNRESTRICTIVE int

Spoofchecker::SINGLE_SCRIPT_RESTRICTIVE int

Spoofchecker::MIXED_NUMBERS int

Spoofchecker::HIDDEN_OVERLAY int

Spoofchecker::IGNORE_SPACE int

Spoofchecker::CASE_INSENSITIVE int

Enables case-insensitive matching

Spoofchecker::ADD_CASE_MAPPINGS int

Adds all case mappings for each element in the set

Spoofchecker::SIMPLE_CASE_INSENSITIVE int

Enables case-insensitive matching

Table of Contents

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。