Re: Kill Magic Quotes

From: Date: Fri, 08 Aug 2008 03:08:38 +0000
Subject: Re: Kill Magic Quotes
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-277859@lists.php.net to get a copy of this message
public static function restoreSlashes($string) { // Check if "Magic Quotes" is turned on. if (get_magic_quotes_gpc()) {
    // Add escape slashes.
    return addslashes($string);
} // Return a string that has escape slashes. return $string; }
Wrong way around. If gpc is enabled, then there are already slashes - no need to add them again. If it's not, you need to addslashes. if (get_magic_quotes_gpc()) { return $string; } return addslashes($string); Though I'm curious why you need to re-add them at all.

« previous php.general (#277859) next »