php/doc-en

Examples for filter_var

オープン

#1,475 opened on 2022/03/23

 (1 件のコメント) (0 件のリアクション) (0 人の担当者)XML (882 件のフォーク)auto 404
Extension: filterenhancementgood first issue

Repository metrics

Stars
 (596 個のスター)
PR merge metrics
 (平均マージ 99d 23h) (30d で 90 merged PRs)

説明

From manual page: https://php.net/function.filter-var


There is no example with if and I saw a lot of implementations like:

if (!filter_var($value, $type)) {
    echo 'error';
}

and it should be:

if (filter_var($value, $type) !== $value) {
    echo 'error';
}

Especially, when you validated with FILTER_VALIDATE_BOOLEAN filter.

コントリビューターガイド