Forum Moderators: coopster
PHP manual recommends the following to encode URLs:
<?php
echo '<a href="mycgi?foo=', htmlentities(urlencode($userinput)), '">';
?>
However this makes little sense to me as urlencode converts everything but -_ to %xx, and % has no equivalent html entity. So htmlentities() will not transform anything in urlencode($userinput).
It would makes sense in this case:
<?php
echo '<a href="mycgi?foo=', htmlentities(urlencode($userinput_1) . '&' . urlencode($userinput_2)), '">';
?>
Then htmlentities is useful as the & get translated into its & entity.
Or am I missing something?
Thanks for your comments.
Cheers,
Cook