Get the current configuration setting of magic_quotes_gpc in PHP
Description
The following code shows how to get the current configuration setting of magic_quotes_gpc.
Example
/* w w w . j a va 2 s.co m*/
<?php
// If magic quotes are enabled
$lastname = '"java2s.com"';
echo $lastname;
echo addslashes($lastname);
// Usage across all PHP versions
if (get_magic_quotes_gpc()) {
$lastname = stripslashes($lastname);
}
// If using MySQL
$lastname = mysql_real_escape_string($lastname);
echo $lastname;
$sql = "INSERT INTO lastnames (lastname) VALUES ('$lastname')";
echo $sql;
?>
The code above generates the following result.