svk
svk

Reputation: 4553

why backslash is added when I pass the value from Jquery to PHP?

When I pass a value from Jquery (For Example test's name) in post method.When I get the the same value in PHP and return it I got like this
test\'s name.I don't know why?
I used the encode URI also.Thanks in advance.

Upvotes: 2

Views: 178

Answers (2)

Alex Pliutau
Alex Pliutau

Reputation: 21937

If your hoster doesn't permit you to change a php configuration, you can use this function for POST, GET.. arrays.

<?php
function stripslashes_deep($value)
{
    $value = is_array($value) ?
                array_map('stripslashes_deep', $value) :
                stripslashes($value);

    return $value;
}
if((function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc())    || (ini_get('magic_quotes_sybase') && (strtolower(ini_get('magic_quotes_sybase'))!="off")) ){
    stripslashes_deep($_GET);
    stripslashes_deep($_POST);
    stripslashes_deep($_COOKIE);
}
?>

Upvotes: 1

Piotr M&#252;ller
Piotr M&#252;ller

Reputation: 5558

You must have magic quotes option turned on in your php.

Try to set

magic_quotes_gpc = Off

in your configuration.

Upvotes: 3

Related Questions