P粉2141766392023-08-15 10:44:53
Use PHP's urlencode()
function to encode the value before putting it in the URL.
This function converts "strange" characters, such as =
, into a format that is safe to put in the URL. You can use it like this:
Header('Location: /index.php?id=' . urlencode($id))
P粉3463260402023-08-15 09:23:14
Strange characters in the value passed in the URL should be escaped using urlencode().
For example, the following code snippet:
echo urlencode('dsf13f3343f23/23=');will give:
dsf13f3343f23%2F23%3DAs a URL parameter, this is valid.
If you want to build a query string with multiple parameters, check out the
http_build_query() function.
echo http_build_query(array( 'id' => 'dsf13f3343f23/23=', 'a' => 'plop', 'b' => '$^@test', ));will give:
id=dsf13f3343f23%2F23%3D&a=plop&b=%24%5E%40testThis function will automatically handle escaping and parameter splicing;-)