本文整理汇总了PHP中Regex::replace方法的典型用法代码示例。如果您正苦于以下问题:PHP Regex::replace方法的具体用法?PHP Regex::replace怎么用?PHP Regex::replace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Regex
的用法示例。
在下文中一共展示了Regex::replace方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: word
public function word($string = '', $badWords = '', $changeChar = '[badwords]')
{
if (!isValue($string)) {
return Error::set(lang('Error', 'valueParameter', 'string'));
}
if (!is_array($badWords)) {
if (empty($badWords)) {
return $string;
}
return $string = Regex::replace($badWords, $changeChar, $string, 'xi');
}
$ch = '';
$i = 0;
if (!empty($badWords)) {
foreach ($badWords as $value) {
if (!is_array($changeChar)) {
$ch = $changeChar;
} else {
if (isset($changeChar[$i])) {
$ch = $changeChar[$i];
$i++;
}
}
$string = Regex::replace($value, $ch, $string, 'xi');
}
}
return $string;
}
示例2: ncEncode
public function ncEncode($string = '', $badWords = '', $changeChar = '[badchars]')
{
if (!is_string($string)) {
return Error::set(lang('Error', 'stringParameter', 'string'));
}
// 2. Parametre boş ise varsayılan olarak Config/Security.php dosya ayarlarını kullan.
if (empty($badWords)) {
$secnc = $this->config['ncEncode'];
$badWords = $secnc['bad_chars'];
$changeChar = $secnc['change_bad_chars'];
}
if (!is_array($badWords)) {
return $string = Regex::replace($badWords, $changeChar, $string, 'xi');
}
$ch = '';
$i = 0;
foreach ($badWords as $value) {
if (!is_array($changeChar)) {
$ch = $changeChar;
} else {
if (isset($changeChar[$i])) {
$ch = $changeChar[$i];
$i++;
}
}
$string = Regex::replace($value, $ch, $string, 'xi');
}
return $string;
}
示例3: internalRouteURI
function internalRouteURI(string $requestUri = '') : string
{
$config = Config::get('Services', 'route');
if ($config['openPage']) {
$internalDir = NULL;
if (defined('_CURRENT_PROJECT')) {
$configAppdir = PROJECTS_CONFIG['directory']['others'];
if (is_array($configAppdir)) {
$internalDir = !empty($configAppdir[$requestUri]) ? $requestUri : _CURRENT_PROJECT;
} else {
$internalDir = _CURRENT_PROJECT;
}
}
if ($requestUri === DIRECTORY_INDEX || $requestUri === getLang() || $requestUri === $internalDir || empty($requestUri)) {
$requestUri = $config['openPage'];
}
}
$uriChange = $config['changeUri'];
$patternType = $config['patternType'];
if (!empty($uriChange)) {
foreach ($uriChange as $key => $val) {
if ($patternType === 'classic') {
$requestUri = preg_replace(presuffix($key) . 'xi', $val, $requestUri);
} else {
$requestUri = Regex::replace($key, $val, $requestUri, 'xi');
}
}
}
return $requestUri;
}
示例4: getController
private static function getController($location)
{
$location = strtolower($location);
$pattern = '/controller/';
$match = Regex::match($pattern, $location);
if ($match > 0) {
$location = Regex::replace($pattern, '', $location);
}
return $location;
}
示例5: find
/**
* @Invocable
*/
protected function find()
{
if ($this->request->hasKey('friend')) {
$name = Regex::replace('/[^A-Za-z0-9]/', '', $this->request->valueOf('friend'));
Navigator::redirectTo($this->url->getParametersPath($name));
}
$name = $this->url->getParameter(0);
if ($name == null) {
return;
}
$this->getUsers($name);
}
示例6: routeUri
function routeUri($requestUri = '')
{
if (Config::get('Route', 'openPage')) {
if ($requestUri === 'index.php' || empty($requestUri) || $requestUri === getLang()) {
$requestUri = Config::get('Route', 'openPage');
}
}
$config = Config::get('Route');
$uriChange = $config['changeUri'];
$patternType = $config['patternType'];
if (!empty($uriChange)) {
foreach ($uriChange as $key => $val) {
if ($patternType === 'classic') {
$requestUri = preg_replace(presuffix($key) . 'xi', $val, $requestUri);
} else {
$requestUri = Regex::replace($key, $val, $requestUri, 'xi');
}
}
}
return $requestUri;
}