PHP Addslashes adding double backslashes when escaping a single quote
<p>Addslashes seems to be a bit confused.  Given the following 2 lines of code</p>

<pre><code>$name = "Dave's test";
$newName = addslashes($name);
</code></pre>

<p>I am <em>expecting</em> $newName to be <strong>"Dave\'s test"</strong> (my one single quote nicely escaped)</p>

<p>However, what I'm <em>getting</em> is <strong>"Dave\\'s test"</strong> (note the DOUBLE backslashes).  This contradicts every bit of online documentation I can find on addslashes - and causing me a lot of grief.</p>

<p>I am dumping the before and after addslashes results to the http error log via error_log...</p>

<pre><code>error_log("before=$name  after=$newName");
</code></pre>

<p>results...</p>

<pre><code>before=Dave's test  after=Dave\\'s test
</code></pre>

<p>Note - this is part of an ajax process, so I can't really 'echo' the results.</p>

<p>Any insights into why addslashes would be double up on the backslases are much appreciated.</p>

<p>FYI: I'm Using PHP 5.2.6 under linux with magic quotes OFF.</p>
