http:// Becomes http%3A%2F%2F in CodeIgniter
Solution 1
When you put strings with special characters into URL, they will be encoded, you can use urldecode
Solution 2
The point of http_build_query()
is that it urlencode()
s each of the array's values for you before joining them in a querystring format. This is the preferred behavior.
Solution 3
The query string is encoded because there are some special characters that have special meaning in a URL.
From Wikipedia:
Some characters cannot be part of a URL (for example, the space) and some other characters have a special meaning in a URL: for example, the character # can be used to further specify a subsection (or fragment) of a document; the character = is used to separate a name from a value. A query string may need to be converted to satisfy these constraints. This can be done using a schema known as URL encoding.

Comments
-
shin 5 months
The following redirect url becomes with http%3A%2F%2F instead of http://. How can I avoid this?
Thanks in advance.
$params = array( 'client_id' => $client_id, 'redirect_uri' => site_url('welcome/google_connect_redirect/'), 'state' => $_SESSION['state'], 'approval_prompt' => 'force', 'scope' => 'https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email', 'response_type' => 'code' ); $url = "https://accounts.google.com/o/oauth2/auth?".http_build_query($params); // send to google redirect($url);
URL becomes like this.
https://accounts.google.com/o/oauth2/auth?client_id=871111192098.apps. googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A8888%2Fmyappname %2Findex.php%2Fwelcome%2Fgoogle_connect_redirect&state=f0babsomeletterscb5b48753358c 3b9&approval_prompt=force&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2F userinfo.profile+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email& response_type=code
-
Explosion Pills over 10 yearsExactly. It's actually a good thing that it's doing this. OP, have you tested it out? Is there a problem?