本文整理汇总了PHP中UTF8::urldecode方法的典型用法代码示例。如果您正苦于以下问题:PHP UTF8::urldecode方法的具体用法?PHP UTF8::urldecode怎么用?PHP UTF8::urldecode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UTF8
的用法示例。
在下文中一共展示了UTF8::urldecode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _entity_decode
/**
* @param $str
*
* @return string
*/
private function _entity_decode($str)
{
static $entities;
$flags = Bootup::is_php('5.4') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
// decode
if (strpos($str, $this->xss_hash()) !== false) {
$str = UTF8::html_entity_decode($str, $flags);
} else {
$str = UTF8::urldecode($str);
}
// decode-again, for e.g. HHVM, PHP 5.3, miss configured applications ...
if (preg_match_all('/&[a-z]{2,}[;]{0}/i', $str, $matches)) {
if (null === $entities) {
// links:
// - http://dev.w3.org/html5/html-author/charref
// - http://www.w3schools.com/charsets/ref_html_entities_n.asp
$entitiesSecurity = array('�' => '', '�' => '', '' => '', '' => '', '>⃒' => '', '' => '', '' => '', '­' => '', '­' => '', '­' => '', ':' => ':', ':' => ':', ':' => ':', '(' => '(', '(' => '(', '(' => '(', ')' => ')', ')' => ')', ')' => ')', '?' => '?', '?' => '?', '?' => '?', '/' => '/', '/' => '/', '/' => '/', ''' => '\'', ''' => '\'', ''' => '\'', ''' => '\'', ''' => '\'', '\' => '\'', '\' => '\\', '\' => '\\', ',' => ',', ',' => ',', ',' => ',', '.' => '.', '.' => '.', '"' => '"', '"' => '"', '"' => '"', '"' => '"', '`' => '`', '`' => '`', '`' => '`', '`' => '`', '.' => '.', '=' => '=', '=' => '=', '=' => '=', '&newline;' => "\n", '
' => "\n", ' ' => "\n", '&tab;' => "\t", '	' => "\n", '	' => "\n");
$entitiesTmp = get_html_translation_table(HTML_ENTITIES, $flags);
$entitiesTmp = array_merge(self::$entitiesFallback, $entitiesTmp);
$entities = array_merge($entitiesSecurity, array_map('strtolower', array_flip($entitiesTmp)));
}
$replace = array();
$matches = array_unique(array_map('strtolower', $matches[0]));
foreach ($matches as $match) {
$match .= ';';
if (array_key_exists($match, $entities) === true) {
$replace[$match] = $entities[$match];
}
}
if (count($replace) > 0) {
$str = str_ireplace(array_keys($replace), array_values($replace), $str);
}
}
return $str;
}
示例2: downcode
/**
* Transliterates characters to their ASCII equivalents.
* $language specifies a priority for a specific language.
* The latter is useful if languages have different rules for the same character.
*
* @param string $string <p>The input string.</p>
* @param string $language <p>Your primary language.</p>
* @param boolean $convertToAsciiOnlyViaLanguageMaps <p>
* Set to <strong>true</strong> if you only want to convert the
* language-maps.
* (better performance, but less complete ASCII converting)
* </p>
* @param boolean $convertUtf8Specials <p>
* Convert (html) special chars with portable-utf8 (e.g. \0,
* \xE9, %F6, ...).
* </p>
* @param string $unknown <p>Character use if character unknown. (default is ?).</p>
*
* @return string
*/
public static function downcode($string, $language = 'de', $convertToAsciiOnlyViaLanguageMaps = false, $unknown = '', $convertUtf8Specials = true)
{
self::init_downcode($language);
if ($convertUtf8Specials === true) {
$string = UTF8::urldecode($string);
}
$searchArray = array();
$replaceArray = array();
if (preg_match_all(self::$regex, $string, $matches)) {
$matchesCounter = count($matches[0]);
/** @noinspection ForeachInvariantsInspection */
for ($i = 0; $i < $matchesCounter; $i++) {
$char = $matches[0][$i];
if (isset(self::$map[$char])) {
$searchArray[] = $char;
$replaceArray[] = self::$map[$char];
}
}
}
$string = str_replace($searchArray, $replaceArray, $string);
if ($convertToAsciiOnlyViaLanguageMaps === true) {
return (string) $string;
}
return UTF8::to_ascii($string, $unknown);
}