<?php
/**
* @desc add slashes if use MySQL and check if function addslashes is exits else
* return to escape string in MySQL .
* same way its return to stripslashes function
* @param string $type any string u want to insert in MySQL and display from MySQL
* @param string $type must be add to add slashes and strip to strip slashes
* @author Yousef Ismaeil - cliprz@gmail.com
*/
function PHP_slashes($string,$type='add')
{
if ($type == 'add')
{
if (get_magic_quotes_gpc())
{
return $string;
}
else
{
if (function_exists('addslashes'))
{
return addslashes($string);
}
else
{
return mysql_real_escape_string($string);
}
}
}
else if ($type == 'strip')
{
return stripslashes($string);
}
else
{
die('error in PHP_slashes (mixed,add | strip)');
}
}
?>