We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9572
    • 56 Posts
    I’m trying to create a simple snippet that takes a string and URL encodes it but I’m a little new to PHP and what I have isnt working

    In usage, the command would be something like the following;
    [[urlencode? &input=`any string you can think of`]]


    and the snippet looks like this;
    $input = (isset($input));
    $output = urlencode($input);
    return $output;


    I know I must be doing something wrong, but given my little PHP experience I can’t tell what it is.
      • 27376
      • 576 Posts
      Change the first line to this:
      $input = (isset($input) ? $input : '');

      isset($input) will simply return (bool)true|false depending on if the variable is set.
        • 9572
        • 56 Posts
        Thanks! that did the trick