drupal_urlencode

Хочешь помочь с переводом? Это очень просто и быстро. Лишь зарегистрируйся, и можешь тут же начать переводить.

includes/common.inc, строка 2468

Версии
5 – 6
drupal_urlencode($text)

Обертка для функции urlencode(), которая позволяет избежать проблем с Апачем.

Следует использовать при размещении произвольных данных в URL. Обратите внимание, что Друпал-пути, которые проходят через функцию URL(), не требуют использования этой функции.

Примечания:

  • For esthetic reasons, we do not escape slashes. This also avoids a 'feature' in Apache where it 404s on any path containing '%2F'.
  • mod_rewrite unescapes %-encoded ampersands, hashes, and slashes when clean URLs are used, which are interpreted as delimiters by PHP. These characters are double escaped so PHP will still see the encoded version.
  • With clean URLs, Apache changes '//' to '/', so every second slash is double escaped.

Параметры

$text String to encode

▾ 4 функции вызывают drupal_urlencode()

drupal_query_string_encode in includes/common.inc
Parse an array into a valid urlencoded query string.
theme_comment_post_forbidden in modules/comment/comment.module
Темизирует уведомление "вы не можете оставить комментарий".
url in includes/common.inc
Генерирует URL из указанного пути меню. Также поддерживает уже существующие URL.
_update_build_fetch_url in modules/update/update.fetch.inc
Generates the URL to fetch information about project updates.

Код

<?php
function drupal_urlencode($text) {
  if (variable_get('clean_url', '0')) {
    return str_replace(array('%2F', '%26', '%23', '//'),
                       array('/', '%2526', '%2523', '/%252F'),
                       rawurlencode($text));
  }
  else {
    return str_replace('%2F', '/', rawurlencode($text));
  }
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии

Вход в систему