I looked into this but I was turned off by the following warning:
I think that their warning is correct, but the solution given ("simply encode your URLs using htmlentities() or htmlspecialchars()") is wrong. From what I understand, you should be encoding your separators as & in the first place. That is, instead of writing:
<a href="index.html?x=1&=2">foo</a>
you should be writing:
<a href="index.html?x=1&amp=2">foo</a>
Consequently, within the context of PHP you would write:
<?php
$x = 1;
$amp = 2;
echo '<a href="index.html?x=' . urlencode($x) . '&amp=' . urlencode($amp) . '">foo</a>';
?>
EDIT:
Actually, I think the relevant advice is "A more portable way around this is to use & instead of & as the separator." The htmlspecialchars() and htmlentities() part is correct in the sense that you do have to do such escaping (for & to & ), and depending on how you write your code you might need them to automate the escaping.