I know I will be voted down for this, but I need to ask. What does the code below mean? Specifically, I am confused by
if (empty($_POST[\"comment\"])) { $comme
test_input()
is a user - defined function used by w3schools:
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
For example:
trim($data)
will strip unnecessary characters (extra space, tab, newline) from the user input data (with the PHP trim() function).stripslashes($data)
will remove backslashes () from the user input data (with the PHP stripslashes() function).htmlspecialchars($data)
converts special characters to HTML entities.
<
and >
, htmlspecialchars() will translate it to <
and >
).