Reputation: 3
I currently working on PHP and at some part of code I generate URL string. I set the GET parameter to currencyCode
. But before I add &
. So, at result I must get ¤cyCode
but get ¤cyCode
.
How do I fix it?
Upvotes: 0
Views: 145
Reputation: 111829
You need to create url this way using urlencode()
function:
<?php
echo 'http://example.com/'.urlencode('¤cyCode');
I also think that your main problem is with displaying it. You should use:
echo htmlspecialchars('¤cyCode');
to display it.
Otherwise it seems browser change the first part of this string into: ¤
entity so you get something like that ¤cyCode
and what makes you have display ¤
symbol what is ¤
and the rest of string cyCode
Upvotes: 2
Reputation: 4275
You should use urlencode()
function in php to encode the url. Your code should look like this
<?php
echo 'http://yoursitename.com/'.urlencode('¤cyCode');
Upvotes: 1