本文整理匯總了PHP中UTF8::remove_invisible_characters方法的典型用法代碼示例。如果您正苦於以下問題:PHP UTF8::remove_invisible_characters方法的具體用法?PHP UTF8::remove_invisible_characters怎麽用?PHP UTF8::remove_invisible_characters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UTF8
的用法示例。
在下文中一共展示了UTF8::remove_invisible_characters方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: _clean_input_data
/**
* Clean Input Data
*
* Internal method that aids in escaping data and
* standardizing newline characters to PHP_EOL.
*
* @param string|string[] $str Input string(s)
* @return string
*/
protected function _clean_input_data($str)
{
if (is_array($str)) {
$new_array = array();
foreach (array_keys($str) as $key) {
$new_array[$this->_clean_input_keys($key)] = $this->_clean_input_data($str[$key]);
}
return $new_array;
}
/* We strip slashes if magic quotes is on to keep things consistent
NOTE: In PHP 5.4 get_magic_quotes_gpc() will always return 0 and
it will probably not exist in future versions at all.
*/
if (!Core::isPHP('5.4') && get_magic_quotes_gpc()) {
$str = stripslashes($str);
}
// Clean UTF-8 if supported
if (UTF8_ENABLED === TRUE) {
$str = $this->factory->utf8->clean_string($str);
}
// Remove control characters
$str = UTF8::remove_invisible_characters($str, FALSE);
// Standardize newlines if needed
if ($this->_standardize_newlines === TRUE) {
return preg_replace('/(?:\\r\\n|[\\r\\n])/', PHP_EOL, $str);
}
return $str;
}
示例2: sanitize_filename
/**
* Sanitize Filename
*
* @param string $str Input file name
* @param bool $relative_path Whether to preserve paths
* @return string
*/
public function sanitize_filename($str, $relative_path = FALSE)
{
$bad = $this->filename_bad_chars;
if (!$relative_path) {
$bad[] = './';
$bad[] = '/';
}
$str = UTF8::remove_invisible_characters($str, FALSE);
do {
$old = $str;
$str = str_replace($bad, '', $str);
} while ($old !== $str);
return stripslashes($str);
}