The difference between them is that the PHP's urlencode encodes spaces with + instead of %20?
urlencode
+
%20
What are the functions that do the same thing for both the languages?
Use rawurlencode instead of urlencode in PHP.
rawurlencode