Skip to content

Instantly share code, notes, and snippets.

@drewlesueur
Created December 29, 2010 19:27
Show Gist options
  • Save drewlesueur/758936 to your computer and use it in GitHub Desktop.
Save drewlesueur/758936 to your computer and use it in GitHub Desktop.
A couple PHP utility functions
// Disable magic quotes
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);
}
function he($i) {
echo htmlspecialchars($i, ENT_QUOTES);
}
function h($i) {
return htmlspecialchars($i, ENT_QUOTES);
}
function empt($what) {
return $what !== 0 && $what !== '0' && empty($what);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment