当前位置: 首页>>代码示例>>PHP>>正文


PHP Regex::replace方法代码示例

本文整理汇总了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;
 }
开发者ID:Allopa,项目名称:ZN-Framework-Starter,代码行数:28,代码来源:Filter.php

示例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;
 }
开发者ID:Allopa,项目名称:ZN-Framework-Starter,代码行数:29,代码来源:Security.php

示例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;
}
开发者ID:znframework,项目名称:znframework,代码行数:30,代码来源:Internal.php

示例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;
 }
开发者ID:anzasolutions,项目名称:simlandia,代码行数:10,代码来源:navigator.class.php

示例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);
 }
开发者ID:anzasolutions,项目名称:simlandia,代码行数:15,代码来源:friendscontroller.class.php

示例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;
}
开发者ID:bytemtek,项目名称:znframework,代码行数:21,代码来源:Functions.php


注:本文中的Regex::replace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。