Skip to content

Instantly share code, notes, and snippets.

@MrXploder
Created May 22, 2018 04:10
Show Gist options
  • Save MrXploder/41a71b7bb61e64d50dcef6048b6f77bb to your computer and use it in GitHub Desktop.
Save MrXploder/41a71b7bb61e64d50dcef6048b6f77bb to your computer and use it in GitHub Desktop.
PHP Function to sanitize a GET variable
<?php
/*
* @param $data (variable) -> can be any valid type
* @author MrXploder
*/
function sanitizeInput($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
//USAGE:
// echo $secureVar = sanitizeInput($_GET["myVar"]);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment