Addslashes seems to be a bit confused. Given the following 2 lines of code
$name = "Dave's test";
$newName = addslashes($name);
I am expecting $newName to be "Dave\'s test" (my one single quote nicely escaped)
However, what I'm getting is "Dave\\'s test" (note the DOUBLE backslashes). This contradicts every bit of online documentation I can find on addslashes - and causing me a lot of grief.
I am dumping the before and after addslashes results to the http error log via error_log...
error_log("before=$name after=$newName");
results...
before=Dave's test after=Dave\\'s test
Note - this is part of an ajax process, so I can't really 'echo' the results.
Any insights into why addslashes would be double up on the backslases are much appreciated.
FYI: I'm Using PHP 5.2.6 under linux with magic quotes OFF.