personal-website/docs/common/utils.php

16 lines
341 B
PHP
Raw Normal View History

2024-04-28 17:37:00 +02:00
<?php
/**
* Sanitize a given input string to be safe to display and process.
*/
function sanitize_input($data) {
// Remove unnecessary whitespace characters
$data = trim($data);
// Remove backslashes
$data = stripslashes($data);
// Escape all special characters to HTML entities
$data = htmlspecialchars($data);
return $data;
}
?>