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


PHP mb_regex_encoding函数代码示例

本文整理汇总了PHP中mb_regex_encoding函数的典型用法代码示例。如果您正苦于以下问题:PHP mb_regex_encoding函数的具体用法?PHP mb_regex_encoding怎么用?PHP mb_regex_encoding使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了mb_regex_encoding函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor.
  *
  * @access protected
  */
 protected function __construct()
 {
     // Init Config
     Config::init();
     // Turn on output buffering
     ob_start();
     // Display Errors
     Config::get('system.errors.display') and error_reporting(-1);
     // Set internal encoding
     function_exists('mb_language') and mb_language('uni');
     function_exists('mb_regex_encoding') and mb_regex_encoding(Config::get('system.charset'));
     function_exists('mb_internal_encoding') and mb_internal_encoding(Config::get('system.charset'));
     // Set default timezone
     date_default_timezone_set(Config::get('system.timezone'));
     // Start the session
     Session::start();
     // Init Cache
     Cache::init();
     // Init Plugins
     Plugins::init();
     // Init Blocks
     Blocks::init();
     // Init Pages
     Pages::init();
     // Flush (send) the output buffer and turn off output buffering
     ob_end_flush();
 }
开发者ID:zorca,项目名称:morfy,代码行数:32,代码来源:Morfy.php

示例2: escape

 public function escape(array $values)
 {
     if (extension_loaded("mbstring")) {
         $toEnc = defined("SDB_MSSQL_ENCODING") ? SDB_MSSQL_ENCODING : "SJIS";
         $fromEnc = mb_internal_encoding();
         $currentRegexEnc = mb_regex_encoding();
         mb_regex_encoding($fromEnc);
         foreach ($values as $k => &$val) {
             if (is_bool($val)) {
                 $val = $val ? "1" : "0";
             } elseif (is_string($val)) {
                 $val = "'" . mb_convert_encoding(mb_ereg_replace("'", "''", $val), $toEnc, $fromEnc) . "'";
             }
         }
         mb_regex_encoding($currentRegexEnc);
     } else {
         foreach ($values as &$val) {
             if (is_bool($val)) {
                 $val = $val ? "1" : "0";
             } elseif (is_string($val)) {
                 $val = "'" . str_replace("'", "''", $val) . "'";
             }
         }
     }
     return $values;
 }
开发者ID:reoring,项目名称:sabel,代码行数:26,代码来源:Statement.php

示例3: stem

 public static function stem($word)
 {
     mb_internal_encoding(self::ENCODING);
     mb_regex_encoding(self::ENCODING);
     $word = mb_strtolower($word);
     $len = mb_strlen($word);
     if ($len <= 2) {
         return self::removeAccent($word);
     }
     $r1 = self::R($word);
     $r2 = self::R($word, $r1);
     $rv = self::RV($word);
     // Step 0: Attached pronoun
     $word = $step0Word = self::step0($word, $r1, $r2, $rv);
     // Step 1: Stadanrd Suffix removal
     $word = $step1Word = self::step1($step0Word, $r1, $r2, $rv);
     // Step 2: Verb Suffix
     if ($step1Word == $step0Word) {
         // Step 2a
         $word = $step2aWord = self::step2a($step1Word, $r1, $r2, $rv);
         // Step 2b
         if ($step1Word == $step2aWord) {
             $word = $step2bWord = self::step2b($step2aWord, $r1, $r2, $rv);
         }
     }
     // Step 3: Residual suffix
     $word = self::step3($word, $r1, $r2, $rv);
     return self::removeAccent($word);
 }
开发者ID:rkmax,项目名称:Stemming,代码行数:29,代码来源:SpanishPorter.php

示例4: yarpp_extract_keywords

function yarpp_extract_keywords($source, $max = 20)
{
    global $overusedwords;
    if (function_exists('mb_split')) {
        mb_regex_encoding(get_option('blog_charset'));
        $wordlist = mb_split('\\s*\\W+\\s*', mb_strtolower($source));
    } else {
        $wordlist = preg_split('%\\s*\\W+\\s*%', strtolower($source));
    }
    // Build an array of the unique words and number of times they occur.
    $tokens = array_count_values($wordlist);
    // Remove the stop words from the list.
    foreach ($overusedwords as $word) {
        unset($tokens[$word]);
    }
    // Remove words which are only a letter
    foreach (array_keys($tokens) as $word) {
        if (function_exists('mb_strlen')) {
            if (mb_strlen($word) < 2) {
                unset($tokens[$word]);
            } else {
                if (strlen($word) < 2) {
                    unset($tokens[$word]);
                }
            }
        }
    }
    arsort($tokens, SORT_NUMERIC);
    $types = array_keys($tokens);
    if (count($types) > $max) {
        $types = array_slice($types, 0, $max);
    }
    return implode(' ', $types);
}
开发者ID:hypenotic,项目名称:slowfood,代码行数:34,代码来源:keywords.php

示例5: run

 public function run($args)
 {
     mb_internal_encoding("UTF-8");
     mb_regex_encoding("UTF-8");
     Yii::app()->setImport(['application.modules.store.models.*']);
     $models = StoreCategory::model()->findAll();
     foreach ($models as $model) {
         $res = preg_replace('/\\s\\s+/', ' ', $model->name_ru);
         if ($res !== FALSE) {
             if (mb_strlen($res) !== mb_strlen($model->name_ru)) {
                 $model->name_ru = $res;
                 $model->update(['name_ru']);
                 print_r($model->id . ' ');
             }
         }
     }
     Yii::import('application.components.spreadsheetReader.SpreadsheetReader');
     $reader = new SpreadsheetReader(Yii::getPathOfAlias('application.components.spreadsheetReader.translates') . '/' . 'site_store_category.ods');
     foreach ($reader as $row) {
         if ($row[0] != 'id') {
             $res = Yii::app()->db->createCommand('
                 UPDATE `site_store_category` SET `name_en`= :row2, `name_zh_cn`= :row3, `name_zh_tw`= :row4 WHERE  `name_ru`= :row1;
             ')->execute([':row1' => $row[1], ':row2' => $row[2], ':row3' => $row[3], ':row4' => $row[4]]);
             print_r($res . ' ' . $row[2] . ' ');
         }
     }
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:27,代码来源:ImportStoreCategoryTranslateCommand.php

示例6: __k_enc

function __k_enc($enc = 'UTF-8')
{
    if (C2_MB) {
        mb_internal_encoding($enc);
        mb_regex_encoding($enc);
    }
}
开发者ID:hornos,项目名称:C2,代码行数:7,代码来源:k.php

示例7: update_server

/**
 * @param announcement  Server announcement string. UTF-8 assumed.
 * @param addr          Remote server address.
 */
function update_server($announcement, $addr)
{
    mb_regex_encoding('UTF-8');
    mb_internal_encoding('UTF-8');
    // First we must determine if the announcement is valid.
    $lines = mb_split("\r\n|\n|\r", $announcement);
    $info = new ServerInfo();
    while (list($line_number, $line) = each($lines)) {
        // Separate the label from the value.
        $colon = strpos($line, ":");
        // It must exist near the beginning.
        if ($colon === false || $colon >= 16) {
            continue;
        }
        $label = substr($line, 0, $colon);
        $value = substr($line, $colon + 1, strlen($line) - $colon - 1);
        if (strlen($value) >= 128) {
            continue;
        }
        // Ensure the label identifies a known property.
        if (isset($info[$label])) {
            // This will be included in the datafile.
            $info[$label] = $value;
        }
    }
    // Also include the remote address.
    $info['at'] = $addr;
    $info['time'] = time();
    // Let's write this info into the datafile.
    write_server($info);
}
开发者ID:laszloekovacs,项目名称:Doomsday-Engine,代码行数:35,代码来源:master.php

示例8: run

 /**
  * Run an application
  */
 public static function run()
 {
     // Error reporting
     error_reporting(ENV === 'production' ? E_ERROR | E_WARNING | E_PARSE : -1);
     ini_set('display_errors', ENV === 'production' ? 0 : 1);
     // Services
     $services = Services::getInstance();
     // Global configuration
     $config = $services->config()->get('config');
     // UTF-8 support
     if (isset($config['utf8']) && $config['utf8']) {
         mb_internal_encoding('UTF-8');
         mb_http_output('UTF-8');
         mb_http_input('UTF-8');
         mb_language('uni');
         mb_regex_encoding('UTF-8');
         ob_start('mb_output_handler');
     } else {
         ob_start();
     }
     // Set Locales
     if (isset($config['locale']) && $config['locale']) {
         setlocale(LC_ALL, $config['locale']);
         setlocale(LC_NUMERIC, 'C');
     }
     // Call controller
     if ($route = $services->route()) {
         list($class, $method, $params) = $route;
         $controller = new $class();
         $controller->{$method}(...$params);
     }
     $services->output()->display(!$services->input()->isClient());
     ob_end_flush();
 }
开发者ID:sugatasei,项目名称:beerawecka,代码行数:37,代码来源:Bootstrap.php

示例9: parse

 /**
  * Parse title of the question by
  * tokenizing it
  * Overrides parent's parse and users mb_split
  * instead of preg_split to be UTF-8 Safe
  * because title can be a UTF-8 string
  *
  * @return array tokens;
  */
 public function parse()
 {
     if (empty($this->origString)) {
         d('string was empty, returning empty array');
         return array();
     }
     \mb_regex_encoding('UTF-8');
     $aTokens = \mb_split('([\\s,;\\"\\?]+)', $this->origString);
     $aTokens = \array_unique($aTokens);
     $aStopwords = getStopwords();
     \array_walk($aTokens, function (&$val) use($aStopwords) {
         $val = \trim($val);
         $val = strlen($val) > 1 && !in_array($val, $aStopwords) ? $val : false;
     });
     /**
      * Remove empty values
      *
      */
     $aTokens = \array_filter($aTokens);
     /**
      * Call array_values to reindex from 0
      * otherwise if filter removed some
      * elements then Mongo will not
      * treat this as normal array
      */
     return \array_values($aTokens);
 }
开发者ID:codigoirreverente,项目名称:LampCMS,代码行数:36,代码来源:TitleTokenizer.php

示例10: loadquestion

    public function loadquestion()
    {
        $session = new Zend_Session_Namespace('game');
        $formQuesten = new Application_Form_LoadQuestion($_POST);
        $this->view->formQuesten = $formQuesten;
        $session->success = 0;
        $success = null;
        $question = "";
        $answer = "";
        $session->success = 0;
        mb_regex_encoding('UTF-8');
        mb_internal_encoding("UTF-8");
        $db = Zend_Registry::get('dbc');
        $db->query('SET NAMES utf8;');
        if (!is_null($db)) {
            $stmt = $db->prepare('SELECT german, english FROM vocable
								WHERE (level = "' . $session->level . '")
								ORDER BY RAND()
								LIMIT 1');
            $stmt->execute();
            $stmt->bind_result($question, $answer);
            $ergebnis = array();
            $i = 0;
            // Array ausgeben
            while ($stmt->fetch()) {
                $ergebnis[$i][0] = $question;
                $ergebnis[$i][1] = $answer;
                $i++;
            }
            $stmt->close();
            return $ergebnis;
        }
    }
开发者ID:rlechner,项目名称:wtprojekt,代码行数:33,代码来源:GameController.php

示例11: _setupMbstring

 function _setupMbstring()
 {
     #ifdef _MBSTRING_LANGUAGE
     if (defined('_MBSTRING_LANGUAGE') && function_exists("mb_language")) {
         if (@mb_language(_MBSTRING_LANGUAGE) != false && @mb_internal_encoding(_CHARSET) != false) {
             define('MBSTRING', true);
         } else {
             mb_language("neutral");
             mb_internal_encoding("ISO-8859-1");
             if (!defined('MBSTRING')) {
                 define('MBSTRING', false);
             }
         }
         if (function_exists('mb_regex_encoding')) {
             @mb_regex_encoding(_CHARSET);
         }
         ini_set('mbstring.http_input', 'pass');
         ini_set('mbstring.http_output', 'pass');
         ini_set('mbstring.substitute_character', 'none');
     }
     #endif
     if (!defined("MBSTRING")) {
         define("MBSTRING", FALSE);
     }
 }
开发者ID:nbuy,项目名称:legacy,代码行数:25,代码来源:Legacy_LanguageManager.class.php

示例12: __construct

 public function __construct()
 {
     global $connection;
     mb_internal_encoding('UTF-8');
     mb_regex_encoding('UTF-8');
     $this->link = new mysqli($this->host, $this->username, $this->password, $this->database);
 }
开发者ID:kgrayjr,项目名称:ezleague,代码行数:7,代码来源:class-db.php

示例13: initPhp

 /**
  * Set up php for zikula install
  *
  * @throws FatalErrorException if settings are not capable of performing install or sustaining Zikula
  */
 public function initPhp()
 {
     $warnings = array();
     if (!function_exists('mb_get_info')) {
         $warnings[] = __('mbstring is not installed in PHP.  Zikula cannot install or upgrade without this extension.');
     }
     if (version_compare(\PHP_VERSION, '5.6.0', '<') && ini_set('mbstring.internal_encoding', 'UTF-8') === false) {
         // mbstring.internal_encoding is deprecated in php 5.6.0
         $currentSetting = ini_get('mbstring.internal_encoding');
         $warnings[] = __f('Could not use %1$s to set the %2$s to the value of %3$s. The install or upgrade process may fail at your current setting of %4$s.', array('ini_set', 'mbstring.internal_encoding', 'UTF-8', $currentSetting));
     }
     if (ini_set('default_charset', 'UTF-8') === false) {
         $currentSetting = ini_get('default_charset');
         $warnings[] = __f('Could not use %1$s to set the %2$s to the value of %3$s. The install or upgrade process may fail at your current setting of %4$s.', array('ini_set', 'default_charset', 'UTF-8', $currentSetting));
     }
     if (mb_regex_encoding('UTF-8') === false) {
         $currentSetting = mb_regex_encoding();
         $warnings[] = __f('Could not set %1$s to the value of %2$s. The install or upgrade process may fail at your current setting of %3$s.', array('mb_regex_encoding', 'UTF-8', $currentSetting));
     }
     if (ini_set('memory_limit', '128M') === false) {
         $currentSetting = ini_get('memory_limit');
         $warnings[] = __f('Could not use %1$s to set the %2$s to the value of %3$s. The install or upgrade process may fail at your current setting of %4$s.', array('ini_set', 'memory_limit', '128M', $currentSetting));
     }
     if (ini_set('max_execution_time', 86400) === false) {
         // 86400 = 24 hours
         $currentSetting = ini_get('max_execution_time');
         if ($currentSetting > 0) {
             // 0 = unlimited time
             $warnings[] = __f('Could not use %1$s to set the %2$s to the value of %3$s. The install or upgrade process may fail at your current setting of %4$s.', array('ini_set', 'max_execution_time', '86400', $currentSetting));
         }
     }
     return $warnings;
 }
开发者ID:Silwereth,项目名称:core,代码行数:38,代码来源:ControllerUtil.php

示例14: wordwrapFilter

 public function wordwrapFilter($value, $length = 60, $separator = "\n", $preserve = false)
 {
     $lines = array();
     $value = str_replace("<p>", "", $value);
     $value = str_replace("</p>", "\n\n", $value);
     $value = preg_replace("/<br\\W*?\\/>/", "\n", $value);
     if (substr($value, -2) == "\n\n") {
         $value = substr($value, 0, -2);
     }
     $previous = mb_regex_encoding();
     mb_regex_encoding(craft()->templates->getTwig()->getCharset());
     $pieces = mb_split($separator, $value);
     mb_regex_encoding($previous);
     foreach ($pieces as $piece) {
         while (!$preserve && mb_strlen($piece, craft()->templates->getTwig()->getCharset()) > $length) {
             $count = count($lines);
             $lines[] = mb_substr($piece, 0, $length, craft()->templates->getTwig()->getCharset());
             $lastSpacePosition = strrpos($lines[$count], ' ', 0);
             $finalCharacters = trim(substr($lines[$count], $lastSpacePosition, 60));
             $lines[$count] = substr($lines[$count], 0, $lastSpacePosition);
             $piece = $finalCharacters . $piece;
             $piece = mb_substr($piece, $length, 2048, craft()->templates->getTwig()->getCharset());
         }
         $lines[] = $piece;
     }
     return implode($separator, $lines);
 }
开发者ID:jackmcgreevy,项目名称:fast,代码行数:27,代码来源:SproutEmailTwigExtension.php

示例15: trim

 static function trim($value, $max_length, $is_html = false)
 {
     if (UTF8::len($value) > $max_length) {
         $value = UTF8::sub($value, 0, $max_length);
         // TODO: replace this with cleanstring of ctools
         $regex = '(.*)\\b.+';
         $matches = array();
         if (function_exists('mb_ereg')) {
             mb_regex_encoding('UTF-8');
             $found = mb_ereg($regex, $value, $matches);
         } else {
             $found = preg_match("/{$regex}/us", $value, $matches);
         }
         if ($found) {
             $value = $matches[1];
         }
         if ($is_html) {
             // Remove scraps of HTML entities from the end of a strings
             $regex = '/(?:<(?!.+>)|&(?!.+;)).*$/s';
             $value2 = preg_replace($regex . 'u', '', $value);
             if (preg_last_error() == 4) {
                 $value = preg_replace($regex, '', $value);
             } else {
                 $value = $value2;
             }
         }
         $value = rtrim($value);
         $value .= '...';
     }
     if ($is_html) {
         $value = self::_filter_htmlcorrector($value);
     }
     return $value;
 }
开发者ID:splitice,项目名称:radical-basic,代码行数:34,代码来源:Truncate.php


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