simple meaning urlencode in php

simple meaning urlencode in php
it is function using when encoding a string to be used in a query part of a url, as a convenient way to pass variables to the next page.
example of urlencode

<?php
echo '<a href="test?bar='urlencode($userinput), '">';
?>