Created
June 2, 2010 16:21
-
-
Save pwlin/422613 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// filter_input examples | |
// Make sure it is an integer | |
$integer = filter_input(INPUT_POST, 'variable_name', FILTER_SANITIZE_NUMBER_INT); | |
// Make it safe to use in a URL | |
$url_string = filter_input(INPUT_POST, 'variable_name', FILTER_SANITIZE_ENCODED); | |
// Make sure it is a valid URL | |
$url = filter_input(INPUT_POST, 'variable_name', FILTER_VALIDATE_URL); | |
// prevent XSS | |
$url = filter_var($url, FILTER_SANITIZE_STRING); | |
// html encode | |
$url = htmlentities($url, ENT_COMPAT, 'UTF-8'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment