I am a beginner in php. I am running the final chapter project named Robin's Nest from the book "Learning PHP, MySQL and JavaScript with jQuery".
In the file function.php, the function sanitizeString
raises the following deprecation error:
Deprecated: Function get_magic_quotes_gpc() is deprecated in C:\xampp2\htdocs\MyProjects\robinsnest\functions.php on line 42.
My version of php is 7.4.3 and I use Xampp on Windows 10 operating system. I checked the PHP manual for the function and saw that the function has been deprecated as of PHP 7.4.0.
How can I modify this function so that it doesn't use the deprecated function get_magic_quotes_gpc()
and still get equivalent functionality as there seem to be no replacement function?
function sanitizeString($var)
{
global $connection;
$var = strip_tags($var);
$var = htmlentities($var);
if (get_magic_quotes_gpc())
$var = stripslashes($var);
return $connection->real_escape_string($var);
}