Function __global->cms_urlencode

Definitions

sources/urls.php

  • Encode a URL component in such a way that it won't get nuked by Apache %2F blocking security, URL encoded '&' mangling, and common ModSecurity blocks. The get_param_string function will map it back. Hackerish but necessary.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: string

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$url_part URLPATH No No required parameter N/A N/A The URL to encode
$can_try_url_schemes ?boolean No No Null N/A N/A Whether we have to consider URL Schemes (null: don't know, look up)

Returns

  • The encoded result
  • Type: URLPATH
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Encode a URL component in such a way that it won't get nuked by Apache %2F blocking security, URL encoded '&' mangling, and common ModSecurity blocks. The get_param_string function will map it back. Hackerish but necessary.
 *
 * @param  URLPATH $url_part The URL to encode
 * @param  ?boolean $can_try_url_schemes Whether we have to consider URL Schemes (null: don't know, look up)
 * @return URLPATH The encoded result
 */

function cms_urlencode(string $url_part, ?bool $can_try_url_schemes = null) : string