PHP URL Encoding / Decoding?

The weird characters in the values passed in the URL should be escaped, using urlencode( ).

The weird characters in the values passed in the URL should be escaped, using urlencode(). For example, the following portion of code : echo urlencode('dsf13f3343f23/23='); would give you : dsf13f3343f23%2F23%3D Which works fine, as an URL parameter. And if you want to build aquery string with several parameters, take a look at the http_build_query() function.

For example : echo http_build_query(array( 'id' => 'dsf13f3343f23/23=', 'a' => 'plop', 'b' => '$^@test', )); will give you : id=dsf13f3343f23%2F23%3D&a=plop&b=%24%5E%40test This function deals with escaping and concatenating the parameters itself ;-).

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)).

There is no use in encrypting parameters. Send it as is: /index. Php?

Id=3 nothing wrong with it.

Unless you are using a social security number or something similar as a primary key. – vichle Apr 14 at 11:16 should you use it as a primary key at all? – Col.

Shrapnel Apr 14 at 11:23 I'm sure there are some applications where it might be useful. – vichle Apr 28 at 21:30.

If you use Base64 to encode the binary value for the URL, there is also a variant with URL and filename safe alphabet. You can use the strtr function to translate one from alphabet to the other: $base64url = strtr($base64, '+/', '-_'); $base64 = strtr($base64url, '-_', '+/'); So you can use these functions to encode and decode base64url: function base64url_encode($str) { return strtr(base64_encode($str), '+/', '-_')); } function base64url_decode($base64url) { return base64_decode(strtr($base64url, '-_', '+/')); } See also my answer on What is a good way to produce an short alphanumeric string from a long md5 hash?

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions