Skip to content

Instantly share code, notes, and snippets.

@trikitrok
Last active June 30, 2024 14:36
Show Gist options
  • Save trikitrok/46d9c0d5944221528dac to your computer and use it in GitHub Desktop.
Save trikitrok/46d9c0d5944221528dac to your computer and use it in GitHub Desktop.
<?php
class Sanitizer
{
public static function sanitizeString($str)
{
$str = stripSlashes($str);
$str = htmlentities($str);
return strip_tags($str);
}
public static function sanitizeArray($input)
{
return array_map(
// Sanitizer::sanitizeString or self::sanitizeString don't work
// but all these different ways would:
// array('Sanitizer','sanitizeString'),
//'Sanitizer::sanitizeString',
//array('self','sanitizeString'),
'self::sanitizeString',
$input
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment