Created
May 22, 2018 04:10
-
-
Save MrXploder/41a71b7bb61e64d50dcef6048b6f77bb to your computer and use it in GitHub Desktop.
PHP Function to sanitize a GET variable
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 | |
/* | |
* @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