本文整理汇总了PHP中fHTML::decode方法的典型用法代码示例。如果您正苦于以下问题:PHP fHTML::decode方法的具体用法?PHP fHTML::decode怎么用?PHP fHTML::decode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fHTML
的用法示例。
在下文中一共展示了fHTML::decode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: makeFriendly
/**
* Changes a string into a URL-friendly string
*
* @param string $string The string to convert
* @return void
*/
public static function makeFriendly($string)
{
$string = fHTML::decode(fUTF8::ascii($string));
$string = strtolower(trim($string));
$string = str_replace("'", '', $string);
$string = preg_replace('#[^a-z0-9\\-]+#', '_', $string);
$string = preg_replace('#_{2,}#', '_', $string);
$string = preg_replace('#_-_#', '-', $string);
return preg_replace('#(^_+|_+$)#D', '', $string);
}
示例2: makeFriendly
/**
* Changes a string into a URL-friendly string
*
* @param string $string The string to convert
* @param integer $max_length The maximum length of the friendly URL
* @param string $delimiter The delimiter to use between words, defaults to `_`
* @param string |$string
* @param string |$delimiter
* @return string The URL-friendly version of the string
*/
public static function makeFriendly($string, $max_length = NULL, $delimiter = NULL)
{
// This allows omitting the max length, but including a delimiter
if ($max_length && !is_numeric($max_length)) {
$delimiter = $max_length;
$max_length = NULL;
}
$string = fHTML::decode(fUTF8::ascii($string));
$string = strtolower(trim($string));
$string = str_replace("'", '', $string);
if (!strlen($delimiter)) {
$delimiter = '_';
}
$delimiter_replacement = strtr($delimiter, array('\\' => '\\\\', '$' => '\\$'));
$delimiter_regex = preg_quote($delimiter, '#');
$string = preg_replace('#[^a-z0-9\\-_]+#', $delimiter_replacement, $string);
$string = preg_replace('#' . $delimiter_regex . '{2,}#', $delimiter_replacement, $string);
$string = preg_replace('#_-_#', '-', $string);
$string = preg_replace('#(^' . $delimiter_regex . '+|' . $delimiter_regex . '+$)#D', '', $string);
$length = strlen($string);
if ($max_length && $length > $max_length) {
$last_pos = strrpos($string, $delimiter, ($length - $max_length - 1) * -1);
if ($last_pos < ceil($max_length / 2)) {
$last_pos = $max_length;
}
$string = substr($string, 0, $last_pos);
}
return $string;
}
示例3: makeFriendly
/**
* Changes a string into a URL-friendly string
*
* @param string $string The string to convert
* @param interger $max_length The maximum length of the friendly URL
* @return string The URL-friendly version of the string
*/
public static function makeFriendly($string, $max_length = NULL)
{
$string = fHTML::decode(fUTF8::ascii($string));
$string = strtolower(trim($string));
$string = str_replace("'", '', $string);
$string = preg_replace('#[^a-z0-9\\-]+#', '_', $string);
$string = preg_replace('#_{2,}#', '_', $string);
$string = preg_replace('#_-_#', '-', $string);
$string = preg_replace('#(^_+|_+$)#D', '', $string);
$length = strlen($string);
if ($max_length && $length > $max_length) {
$last_pos = strrpos($string, '_', ($length - $max_length - 1) * -1);
if ($last_pos < ceil($max_length / 2)) {
$last_pos = $max_length;
}
$string = substr($string, 0, $last_pos);
}
return $string;
}