本文整理汇总了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);
}