The following PHP code:
<?php
$s = "page.com?a=1¤t";
echo $s;
outputs the unexpected:
page.com?a=1¤t
Setting the file encoding to utf-8 didn't work. When I set $s
to "page.com?a=1&curre", the output is as expected.
I want to know if this is because in my project I have $url
, which needs to be appended with "¤tPage=1".
What is causing this problem?
That's the entity code for the currency symbol being interpreted. If you're building your GET url, you can solve it in various ways:
Use urlencode()
on your query values:
$s = 'page.com?' . urlencode("a=1¤tPage=2");
Use the entity for &
itself;
'page.com?a=1&currentPage=2'
Or use your variable at the beginning so no &
is required:
'page.com?currentPage=2&a=1'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With