Page MenuHomePhorge

function phutil_escape_uri($string)
libphutil Technical Documentation (Core Utilities)

Escape text for inclusion in a URI or a query parameter. Note that this method does NOT escape '/', because "%2F" is invalid in paths and Apache will automatically 404 the page if it's present. This will produce correct (the URIs will work) and desirable (the URIs will be readable) behavior in these cases:

'/path/?param='.phutil_escape_uri($string);         # OK: Query Parameter
'/path/to/'.phutil_escape_uri($string);             # OK: URI Suffix

It will potentially produce the WRONG behavior in this special case:

'/path/to/'.phutil_escape_uri($string).'/thing/';   # BAD: URI Infix

In this case, any '/' characters in the string will not be escaped, so you will not be able to distinguish between the string and the suffix (unless you have more information, like you know the format of the suffix). For infix URI components, use phutil_escape_uri_path_component() instead.

Parameters
string$stringSome string.
Return
stringURI encoded string, except for '/'.