How to pass '+' sign with Curl??

Discussion in 'PHP' started by prometheus, Oct 26, 2008.

Thread Status:
Not open for further replies.
  1. #1
    Hi,
    When you try to make a post request with curl, '+' signs in a variable bocomes ' ', space.

    Lets give an example;
    $var = "http://forums.digitalpoint.com/this+is+a+message.html"

    After posting this variable with curl, variable is transmitted as follow;
    $var = "http://forums.digitalpoint.com/this is a message.html"

    Any idea to fix this issue?
    thanks
     
    prometheus, Oct 26, 2008 IP
  2. SEOAnalytic.com

    SEOAnalytic.com Member

    Messages:
    106
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    26
    #2
    you should use urlencode($var)
    $str='this is text';
    $str=urlencode($str);
    echo $str; //echoes 'this+is+text'
    echo urldecode($str); /echoes 'this is text'
     
    SEOAnalytic.com, Oct 26, 2008 IP
  3. Kyosys

    Kyosys Peon

    Messages:
    226
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    str_replace("+","%2b",$var)

    for only altering the plus sign, otherwise use urlencode
     
    Kyosys, Oct 26, 2008 IP
  4. prometheus

    prometheus Banned

    Messages:
    880
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #4
    wow, it works.
    thank you, sent you a gift :p
     
    prometheus, Oct 26, 2008 IP
  5. Kyosys

    Kyosys Peon

    Messages:
    226
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Wow, thanks
     
    Kyosys, Oct 26, 2008 IP
Thread Status:
Not open for further replies.