About urLdecode and rawurldecode

Discussion in 'PHP' started by receiver, May 21, 2009.

  1. #1
    I have tried following coding:

    <?php echo urlencode($action[0]).'<br/>' ;?>
    <?php echo urldecode($action[0]).'<br/>' ;?>
    <?php echo urlencode(rawurldecode($action[0])).'<br/>' ;?>
    <?php echo rawurldecode(urlencode($action[0])).'<br/>';?>
    <?php echo rawurldecode($action[0]).'<br/>';?>
    <?php echo $action[0].'<br/>'?>
    <?php echo urldecode($action[0]).'<br/>' ;?>
    <?php echo urldecode(rawurldecode($action[0])).'<br/>' ;?>
    <?php echo rawurldecode(urldecode($action[0])).'<br/>' ;?>
    <?php echo urldecode(rawurlencode($action[0])).'<br/>' ;?>
    <?php echo urldecode(rawurldecode($action[0])).'<br/>' ;?>
    <?php echo rawurldecode($action[0]).'<br/>' ;?>
    PHP:

    the following are the outputs:
    cpl198+publisher%40gmail.com
    cpl198 publisher@gmail.com
    cpl198+publisher%40gmail.com
    cpl198+publisher@gmail.com
    cpl198 publisher@gmail.com
    cpl198 publisher@gmail.com
    cpl198 publisher@gmail.com
    cpl198 publisher@gmail.com
    cpl198 publisher@gmail.com
    cpl198 publisher@gmail.com
    cpl198 publisher@gmail.com
    cpl198 publisher@gmail.com

    I want it to be display as cpl198%2B@gmail.com. $action[0] is a email address that from url using GET method.

    Do you have any idea for solving this question?

    Thank you.
     
    receiver, May 21, 2009 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    First - why would you want to add a "+"-sign to the emailaddress? Gmail (and most other email-servers) disregards "+" or at least everything after the "+" and before the "@".

    Ie:

    is exactly the same as johndoe+margareth@gmail.com

    So... I don't really see why you would want to do a "cpl198+@gmail.com" as it will be exactly the same as "cpl198@gmail.com"
     
    PoPSiCLe, May 21, 2009 IP
  3. receiver

    receiver Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    In this case, i have few accounts type etc. cpl198+publisher@gmail.com, cpl198+datacenter@gmail.com and many more.
    Hence, i need it for my works.
     
    receiver, May 21, 2009 IP
  4. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #4
    This works for me:
    
    <?php $action = "cpl198+publisher@gmail.com"; ?>
    <?php $action = explode ("@",$action); ?>
    <?php echo urlencode($action[0])."@".$action[1]; ?>
    
    PHP:
    Given, I just gave the $action-variable a value, but the output works as intended, at least. It gives the following output: cpl198%2Bpublisher@gmail.com
     
    PoPSiCLe, May 21, 2009 IP