Created
April 6, 2014 02:02
-
-
Save chtombleson/10000598 to your computer and use it in GitHub Desktop.
PHP sanitize function.
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 | |
function get_param($key, $filter=FILTER_SANITIZE_STRING) { | |
if (!isset($_GET[$key])) { | |
return null; | |
} | |
return filter_var($_GET[$key], $filter); | |
} | |
function post_param($key, $filter=FILTER_SANITIZE_STRING) { | |
if (!isset($_POST[$key])) { | |
return null; | |
} | |
return filter_var($_POST[$key], $filter); | |
} | |
function cookie_param($key, $filter=FILTER_SANITIZE_STRING) { | |
if (!isset($_COOKIE[$key])) { | |
return null | |
} | |
return filter_var($_COOKIE[$key], $filter); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment