本文整理匯總了PHP中f::save_name方法的典型用法代碼示例。如果您正苦於以下問題:PHP f::save_name方法的具體用法?PHP f::save_name怎麽用?PHP f::save_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類f
的用法示例。
在下文中一共展示了f::save_name方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: sanitize
function sanitize($string, $type = 'str', $default = null)
{
$string = stripslashes((string) $string);
$string = urldecode($string);
$string = str::utf8($string);
switch ($type) {
case 'int':
$string = (int) $string;
break;
case 'str':
$string = (string) $string;
break;
case 'array':
$string = (array) $string;
break;
case 'nohtml':
$string = self::unhtml($string);
break;
case 'noxml':
$string = self::unxml($string);
break;
case 'enum':
$string = in_array($string, array('y', 'n')) ? $string : $default;
$string = in_array($string, array('y', 'n')) ? $string : 'n';
break;
case 'checkbox':
$string = $string == 'on' ? 'y' : 'n';
break;
case 'url':
$string = v::url($string) ? $string : '';
break;
case 'email':
$string = v::email($string) ? $string : '';
break;
case 'plain':
$string = str::unxml($string);
$string = str::unhtml($string);
$string = str::trim($string);
break;
case 'lower':
$string = str::lower($string);
break;
case 'upper':
$string = str::upper($string);
break;
case 'words':
$string = str::sanitize($string, 'plain');
$string = preg_replace('/[^\\pL]/u', ' ', $string);
case 'tags':
$string = str::sanitize($string, 'plain');
$string = preg_replace('/[^\\pL\\pN]/u', ' ', $string);
$string = str::trim($string);
case 'nobreaks':
$string = str_replace('\\n', '', $string);
$string = str_replace('\\r', '', $string);
$string = str_replace('\\t', '', $string);
break;
case 'url':
$string = self::urlify($string);
break;
case 'filename':
$string = f::save_name($string);
break;
}
return trim($string);
}