Start · Sprachen · PHP · Referenz · filter_input

filter_input

Funktion

Kombiniert Superglobal-Zugriff und Validierung — <code>$_GET</code>, <code>$_POST</code>, <code>$_COOKIE</code>, <code>$_SERVER</code>, <code>$_ENV</code> sicher lesen.

seit PHP 5.2.0 Kategorie: string

Signatur

filter_input(int $type, string $var_name, int $filter = FILTER_DEFAULT, array|int $options = 0): mixed

Beschreibung

Types: INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, INPUT_ENV.

Parameter

Name Typ Default Beschreibung
$type Pflicht int Input-Quelle.
$var_name Pflicht string Key.
$filter int FILTER_DEFAULT Filter.
$options array|int 0 Optionen.

Rückgabewert

Typ
mixed
Beschreibung
Gefilterter Wert.

Beispiele

Sichere Pagination

<?php

$page = filter_input(INPUT_GET, 'page', FILTER_VALIDATE_INT, [
    'options' => ['default' => 1, 'min_range' => 1],
]);