7.x common.inc drupal_encode_path($path)

Encodes a Drupal path for use in a URL.

For aesthetic reasons slashes are not escaped.

Note that url() takes care of calling this function, so a path passed to that function should not be encoded in advance.


$path: The Drupal path to encode.

Related topics

2 calls to drupal_encode_path()
DrupalPublicStreamWrapper::getExternalUrl in includes/stream_wrappers.inc
Overrides getExternalUrl().
url in includes/common.inc
Generates an internal or external URL.


includes/common.inc, line 634
Common functions that many Drupal modules will need to reference.


function drupal_encode_path($path) {
  return str_replace('%2F', '/', rawurlencode($path));


jhodgdon’s picture

In Drupal 6, the corresponding function is http://api.drupal.org/api/function/drupal_urlencode/6