PHP Velho Oeste 2024

Spoofchecker::isSuspicious

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

Spoofchecker::isSuspicious指定されたテキストに、疑わしい文字が含まれていないかをチェックする

説明

public Spoofchecker::isSuspicious(string $string, int &$errorCode = null): bool

指定された文字列に、見た目は殆ど同じように見えるが、 Unicode 文字的には異なる、疑わしい文字が含まれているかを調べます。

パラメータ

string

調べる文字列

errorCode

整数のリファレンスを設定します。 エラーがあった場合には、 エラーコード値を含みます。

戻り値

疑わしい文字が含まれている場合は true を、 そうでない場合は false を返します。

例1 Spoofchecker::isSuspicious() の例

<?php
$checker
= new Spoofchecker();

$checker->isSuspicious('google.com'); // FALSE: only ASCII characters

$checker->isSuspicious('Рaypal.com'); // TRUE
// The first letter is from Cyrylic, not a regular latin "P"

add a note add a note

User Contributed Notes 1 note

up
0
Anonymous
7 years ago
Example of usage:

$checker = new Spoofchecker();

// false: all letters are in ASCII
var_dump($checker->isSuspicious("goog1e.com"));
// true: the first Cyrillic letter is from different set
var_dump($checker->isSuspicious("Рaypal.com"));

This came from
http://stackoverflow.com/questions/17458876/php-spoofchecker-class
To Top