本文整理汇总了PHP中aTools::strtolower方法的典型用法代码示例。如果您正苦于以下问题:PHP aTools::strtolower方法的具体用法?PHP aTools::strtolower怎么用?PHP aTools::strtolower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类aTools
的用法示例。
在下文中一共展示了aTools::strtolower方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doClean
/**
* @see sfValidatorBase
*/
protected function doClean($value)
{
$clean = (string) parent::doClean($value);
$clean = aTools::strtolower($clean);
$slugified = aTools::slugify($clean, $this->getOption('allow_slashes'));
if ($this->getOption('strict')) {
if ($slugified !== $clean) {
throw new sfValidatorError($this, 'invalid', array('value' => $value));
}
} else {
$clean = $slugified;
}
return $clean;
}
示例2: slugify
public static function slugify($path, $allowSlashes = false)
{
// This is the inverse of the method above
if (function_exists('mb_strtolower')) {
// UTF-8 capable replacement for \W. Works fine for English and also for Greek, etc.
$alnum = '\\p{L}\\p{N}_';
$modifier = 'u';
} else {
$alnum = '\\w';
$modifier = '';
}
if ($allowSlashes) {
$alnum .= '\\/';
}
$regexp = "/[^{$alnum}\\-]+/{$modifier}";
$path = aTools::strtolower(preg_replace("/[^{$alnum}\\-]+/{$modifier}", '-', $path));
if ($allowSlashes) {
// No multiple consecutive /
$path = preg_replace("/\\/+/{$modifier}", "/", $path);
// No trailing /
$path = preg_replace("/\\/\$/{$modifier}", '', $path);
}
// No consecutive dashes
$path = preg_replace("/-+/{$modifier}", '-', $path);
// Leading and trailing dashes are silly. This has the effect of trim()
// among other sensible things
$path = preg_replace("/^-*(.*?)-*\$/{$modifier}", '$1', $path);
return $path;
}