how to pass a + sign to php

Discussion in 'JavaScript' started by darkmessiah, Dec 1, 2007.

  1. #1
    I'm having a terible time doing this

    
    var somevalue = "variable+variable";
    var somevalue = 'val+val';
    var somevalue = 'val\+val';
    
    Code (markup):
    none of these work

    php reads that as "variable variable" I need the + sign in there some how. If I escape the + sign with \, the browser complains that some other variable isn't declared. Javascript shows the +, but php is being a pain.

    php is reading that with
    $_GET['somevar'];
    Code (markup):
    please help, Thanks.
     
    darkmessiah, Dec 1, 2007 IP
  2. darkmessiah

    darkmessiah Peon

    Messages:
    500
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #2
    nevermind, in php i just needed to use urldecode on the javascript that had
    var val='val1%2Bval2';
    Code (markup):
     
    darkmessiah, Dec 1, 2007 IP
  3. darkmessiah

    darkmessiah Peon

    Messages:
    500
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #3
    My other fix is to read the javascript string and convert the + to %2b, and pass that to php.
     
    darkmessiah, Dec 2, 2007 IP