0

I want to create a redirect in PHP where I want to pass + sign as %2B in URL but whenever, I'm using header("Location: url ") . It is passing the + sign as +, So at the end server, after decoding it is showing a blank space instead of showing + sign.

<?php

    echo $eqn=$_GET['eqn'];
    $ord=$_GET['ord'];

    

    header("Location: http://example.com/$eqn")
?>

Basically, I've created a HTML form where I am passing data to the following php page, Here I want to redirect to a url like http://example.com?i0=encoded-value-required/aa. And here in the encoded-value-required parameter, I want to pass the + sign as %2B in the header location.

meewog
  • 1,690
  • 1
  • 22
  • 26

1 Answers1

0

Like ADyson wrote you should use urlencode.

$eqn = urlencode($_GET['eqn']);
amiad
  • 478
  • 2
  • 7
  • Is this advice duplicated ANYWHERE on Stack Overflow before today? If so, please close as a duplicate instead of answering. – mickmackusa Mar 01 '22 at 10:52