php/doc-en

Examples for filter_var

Aberta

#1.475 aberto em 23 de mar. de 2022

 (1 comentário) (0 reação) (0 responsável)XML (882 forks)auto 404
Extension: filterenhancementgood first issue

Métricas do repositório

Stars
 (596 estrelas)
Métricas de merge de PR
 (Mesclagem média 99d 23h) (90 fundiu PRs em 30d)

Description

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.

Guia do colaborador