In live server unwanted slashes appending to encoding JSON, wherever single quote present.
Actually i'm trying to do rename Number as Nu'mber, just adding a single in between.
PHP Version 5.3.21
Result: {"values":"Nu\\'mber","lastvalue":"Number"}
i.e. ' replaced with \\'
whereas in my local-server, its working perfectly
PHP Version 5.3.13
Result: {"values":"Nu'mber","lastvalue":"Number"}
Also, i used stripslashes(), but no use of it. in some cases, i have to reuse the result JSON if i do that, more slashes appended .is this PHP version problem?
This has to do with magic quotes. You can turn them off in php.ini or in the code.
From te manual, in php.ini:
; Magic quotes for incoming GET/POST/Cookie data.
magic_quotes_gpc = Off
; Magic quotes for runtime-generated data, e.g. data from SQL, from exec(), etc.
magic_quotes_runtime = Off
; Use Sybase-style magic quotes (escape ' with '' instead of \').
magic_quotes_sybase = Off
Or in your php code:
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);
}