Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] filter_input()
Forum PHP.pl > Forum > PHP
rocktech.pl
Witam.

Czy ktoś mi powie jak i czy w ogóle możliwe jest nadpisanie zmiennej przekazanej do filter_input?

  1.  
  2. <?php
  3. $_GET['search'] = 'foo';
  4.  
  5. $search = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_STRING);
  6. echo "You have searched for $search";
  7.  
  8. ?>

Wynik:
  1. You have searched for";


https://github.com/php/php-src/blob/master/...filter/filter.c ph34r.gif
nospor
Identyko przykład z manuala wraz z rozwiązaniem zagadki....
Cytat
Note that this function doesn't (or at least doesn't seem to) actually filter based on the current values of $_GET etc. Instead, it seems to filter based off the original values.
<?php
$_GET['search'] = 'foo'; // This has no effect on the filter_input

$search_html = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_SPECIAL_CHARS);
$search_url = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_ENCODED);
echo "You have searched for $search_html.\n";
echo "<a href='?search=$search_url'>Search again.</a>";
?>

If you need to set a default input value and filter that, use filter_var on your required input variable instead
rocktech.pl
Przykład jest właśnie z tego cytatu smile.gif

A pogrubienie to właśnie ta zagadka.

Cytat
Note that this function doesn't (or at least doesn't seem to) actually filter based on the current values of $_GET etc. Instead, it seems to filter based off the original values.


Ta funkcja nie (lub przynajmniej nie wydaje się że) filtruje bazując na aktualniej wartości $_GET. Zamiast tego wydaje się, że bazuje na oryginalnych wartościach.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.