CKTIS / PHP
filter_input()
Prečíta pôvodné vstupné pole SAPI a použije zvolený filter.
Verzia: PHP 8.4; repository runtime, production runtime not attested
Syntax
filter_input(int $type, string $var_name, int $filter = FILTER_DEFAULT, array|int $options = 0): mixedPrečíta pôvodné vstupné pole SAPI a použije zvolený filter. Neskoršia zmena $_GET toto pole nezmení. Chýbajúce pole bežne vráti null a neúspešná validácia false. FILTER_NULL_ON_FAILURE tieto dve hodnoty vymení.
Signatúra
filter_input(int $type, string $var_name, int $filter = FILTER_DEFAULT, array|int $options = 0): mixed
Výstup príkladu
[null,false,8]
Príklady
<?php
$_GET["page"]="8";
echo json_encode([filter_input(INPUT_GET,"page",FILTER_VALIDATE_INT),filter_input(INPUT_GET,"page",FILTER_VALIDATE_INT,FILTER_NULL_ON_FAILURE),filter_var($_GET["page"],FILTER_VALIDATE_INT)]);
Výsledok
[null,false,8]