Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHP sanitize function.
<?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
You can’t perform that action at this time.