php mengubah string ke friendly url

<?php
echo '<a href="mycgi?foo=', urlencode($userinput), '">';
?>
Thoughtless Tortoise