Skip to content

Instantly share code, notes, and snippets.

@irazasyed
Last active March 5, 2022 01:01
Show Gist options
  • Save irazasyed/4cfecc00a1928fd4aa73 to your computer and use it in GitHub Desktop.
Save irazasyed/4cfecc00a1928fd4aa73 to your computer and use it in GitHub Desktop.
PHP: XSS Protection.
<?php
/* Prevent XSS - Trims and Sanitizes GET/POST Data */
$_GET = array_map(function ($param) {
return strip_tags(trim(addslashes(htmlspecialchars($param))));
}, $_GET);
$_POST = array_map(function ($param) {
return htmlspecialchars(addslashes(trim($param)));
}, $_POST);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment