How can I prevent htmlentities() from being automatically applied to POST variables on my server?
By default, PHP automatically applies htmlentities() to POST variables for security reasons, which can sometimes cause issues with certain data inputs. To prevent this automatic behavior, you can disable the magic_quotes_gpc directive in your PHP configuration or use the following code snippet at the beginning of your script to revert the behavior:
if (get_magic_quotes_gpc()) {
$process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
while (list($key, $val) = each($process)) {
foreach ($val as $k => $v) {
unset($process[$key][$k]);
if (is_array($v)) {
$process[$key][stripslashes($k)] = $v;
$process[] = &$process[$key][stripslashes($k)];
} else {
$process[$key][stripslashes($k)] = stripslashes($v);
}
}
}
unset($process);
}