PHP URL Encoding / Decoding

前端 未结 4 566
生来不讨喜
生来不讨喜 2020-11-29 12:59

I used the solution accepted for this question for encrypting by id for example in /index.php?id=3 . The problem is I cannot send the encrypted value as an

4条回答
  •  有刺的猬
    2020-11-29 13:57

    Use PHP's urlencode() function to encode the value before you put it into a URL.

    string urlencode ( string $str )
    This function is convenient when encoding a string to be used in a query part of a URL, as a convenient way to pass variables to the next page.

    This function converts "weird" characters, such as =, into a format safe to put into a URL. You can use it like this:

    Header('Location: /index.php?id=' . urlencode($id))
    

提交回复
热议问题