phpencoding

prevent php from automatically encoding '@' to '-'


I have this code using email addresses:

$a = "b@b.com"; 
$b = 'b%40b.com';
$c = urldecode($b);
    
echo ($a . ' ' . $c);

On the browser, both variables are displayed correctly: b@b.com

But if I use $a or $c on the server as username to read the user's account, I get errors because their values are: b—b.com.

If I use the debugger to check the value of $a immediately after the first line of code, then it shows that $a already has the b—b.com value. So there are no extra steps that could encode it.

Note that — is not the html code of the @ sign, but the code for a dash (-).

I tried str_replace(), but it does not work.

PHP Version 5.3.8


Solution

  • Okay I find that it still works right inside the controller as well - although the debugger shows the value of the @ as being —.

    But it is still weird. Maybe it is just a debugger issue, because everything else looks fine. Thanx.

    Update: It is a debugger bug, which they said they will fix. Thanx.