0

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 &currencyCode but get ¤cyCode.

How do I fix it?

1
  • 1
    Take a look at http_build_query Commented Aug 15, 2014 at 11:47

2 Answers 2

2

You need to create url this way using urlencode() function:

<?php

   echo 'http://example.com/'.urlencode('&currencyCode');

I also think that your main problem is with displaying it. You should use:

echo htmlspecialchars('&currencyCode');

to display it.

Otherwise it seems browser change the first part of this string into: &curren; entity so you get something like that &curren;cyCode and what makes you have display &curren; symbol what is ¤ and the rest of string cyCode

Sign up to request clarification or add additional context in comments.

Comments

1

You should use urlencode() function in php to encode the url. Your code should look like this

<?php
echo 'http://yoursitename.com/'.urlencode('&currencyCode');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.