Simple User Input Sanitization in PHP


Sanitize a string input using filter_var() with FILTER_SANITIZE_STRING.

Source Code

$userInput = "alert('hack');";
$safeInput = filter_var($userInput, FILTER_SANITIZE_STRING);
echo $safeInput;
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments