W3cubDocs

/Drupal 8

public static function UrlHelper::encodePath

public static UrlHelper::encodePath($path)

Encodes a Drupal path for use in a URL.

For aesthetic reasons slashes are not escaped.

Parameters

string $path: The Drupal path to encode.

Return value

string The encoded path.

File

core/lib/Drupal/Component/Utility/UrlHelper.php, line 193

Class

UrlHelper
Helper class URL based methods.

Namespace

Drupal\Component\Utility

Code

public static function encodePath($path) {
  return str_replace('%2F', '/', rawurlencode($path));
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Utility!UrlHelper.php/function/UrlHelper::encodePath/8.1.x