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


PHP UTF8::strpos方法代码示例

本文整理汇总了PHP中UTF8::strpos方法的典型用法代码示例。如果您正苦于以下问题:PHP UTF8::strpos方法的具体用法?PHP UTF8::strpos怎么用?PHP UTF8::strpos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UTF8的用法示例。


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

示例1: before

 /**
  * Before action
  */
 public function before()
 {
     parent::before();
     // Получаем статус ошибки
     $status = (int) $this->request->action();
     // Если вызов из строки браузера (http://example.com/error/500)
     if (Request::$initial === Request::$current) {
         $status = 404;
         $this->response->status($status);
         $this->request->action($status);
     } else {
         // Если кода ошибки нет в списке обрабатываемых
         if (!in_array($status, [403, 404, 500, 503])) {
             $status = 404;
             $this->response->status($status);
             $this->request->action($status);
         } else {
             $this->response->status($status);
             $message = $this->request->param('message');
             // Если стандартное сообщение 404
             if (UTF8::strpos($message, 'Unable to find a route to match the URI') !== false) {
                 // Не будем выводить message
                 //$message = '';
             }
         }
     }
     $this->content = View::factory('errors/' . $status)->bind('message', $message);
 }
开发者ID:eok8177,项目名称:shopCMS,代码行数:31,代码来源:Error.php

示例2: _strpos

/**
 * UTF8::strpos
 *
 * @package    JsonApiApplication
 * @author     JsonApiApplication Team
 * @copyright  (c) 2007-2012 JsonApiApplication Team
 * @copyright  (c) 2005 Harry Fuecks
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 */
function _strpos($str, $search, $offset = 0)
{
    $offset = (int) $offset;
    if (UTF8::is_ascii($str) and UTF8::is_ascii($search)) {
        return strpos($str, $search, $offset);
    }
    if ($offset == 0) {
        $array = explode($search, $str, 2);
        return isset($array[1]) ? UTF8::strlen($array[0]) : FALSE;
    }
    $str = UTF8::substr($str, $offset);
    $pos = UTF8::strpos($str, $search);
    return $pos === FALSE ? FALSE : $pos + $offset;
}
开发者ID:benshez,项目名称:DreamWeddingCeremomies,代码行数:23,代码来源:strpos.php

示例3: test_strpos

 /**
  * Tests UTF8::strpos
  *
  * @test
  * @dataProvider provider_strpos
  */
 public function test_strpos($input, $str, $offset, $expected)
 {
     $this->assertSame($expected, UTF8::strpos($input, $str, $offset));
     UTF8::$server_utf8 = !UTF8::$server_utf8;
     $this->assertSame($expected, UTF8::strpos($input, $str, $offset));
     UTF8::$server_utf8 = !UTF8::$server_utf8;
 }
开发者ID:azuya,项目名称:Wi3,代码行数:13,代码来源:UTF8Test.php

示例4: strpos

 /**
  * Finds position of first occurrence of a UTF-8 string. This is a
  * UTF8-aware version of [strpos](http://php.net/strpos).
  *
  * $position = UTF8::strpos($str, $search);
  *
  * @author  Harry Fuecks <hfuecks@gmail.com>
  * @param   string   haystack
  * @param   string   needle
  * @param   integer  offset from which character in haystack to start searching
  * @return  integer  position of needle
  * @return  boolean  FALSE if the needle is not found
  * @uses	IS_MBSTRING
  */
 public static function strpos($str, $search, $offset = 0)
 {
     $offset = (int) $offset;
     if (IS_MBSTRING) {
         return mb_strpos($str, $search, $offset, Core::$charset);
     }
     if (UTF8::is_ascii($str) && UTF8::is_ascii($search)) {
         return strpos($str, $search, $offset);
     }
     if ($offset == 0) {
         $array = explode($search, $str, 2);
         return isset($array[1]) ? UTF8::strlen($array[0]) : FALSE;
     }
     $str = UTF8::substr($str, $offset);
     $pos = UTF8::strpos($str, $search);
     return $pos === FALSE ? FALSE : $pos + $offset;
 }
开发者ID:xiaodin1,项目名称:myqee,代码行数:31,代码来源:utf8.class.php

示例5: goodbrowser

 private function goodbrowser()
 {
     $browser = 'good';
     if (UTF8::strpos($_SERVER['HTTP_USER_AGENT'], 'Opera')) {
         $browser = 'bad';
     }
     if (UTF8::strpos($_SERVER['HTTP_USER_AGENT'], 'OPR')) {
         $browser = 'bad';
     }
     if (UTF8::strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE')) {
         $browser = 'bad';
     }
     if ($browser == 'good') {
         return TRUE;
     }
     return FALSE;
 }
开发者ID:HappyKennyD,项目名称:teest,代码行数:17,代码来源:Books.php

示例6: test_strpos

 /**
  * Tests UTF8::strpos
  *
  * @test
  * @dataProvider provider_strpos
  */
 public function test_strpos($input, $str, $offset, $expected)
 {
     $this->assertSame($expected, UTF8::strpos($input, $str, $offset));
 }
开发者ID:reznikds,项目名称:Reznik,代码行数:10,代码来源:UTF8Test.php

示例7:

  <div id="ptb_err">
    <div class="head">
      <div class="type"><?php 
    echo $class;
    ?>
 <span class="typeCode">[ <?php 
    echo $code;
    ?>
 ]</span></div>
      <div class="message">
      <?php 
    if ($class == 'Database_Exception') {
        ?>
      <?php 
        $start = UTF8::strpos($message, '[ ');
        $end = UTF8::strpos($message, ' ]');
        $sql = UTF8::substr($message, $start + 2, $end - $start - 2);
        $message = UTF8::substr($message, 0, $start);
        ?>
        <?php 
        echo $message;
        ?>
        <?php 
        if ($highlightSQL) {
            ?>
          <pre class="source sql"><?php 
            echo ProfilerToolbar::highlight($sql, 'sql');
            ?>
</pre>
        <?php 
        } else {
开发者ID:tscms,项目名称:profilertoolbar,代码行数:31,代码来源:error.php

示例8: _stripos

/**
 * UTF8::stripos
 *
 * @copyright  (c) 2015 Ivan Tcholakov
 * @license    http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
 */
function _stripos($str, $search, $offset = 0)
{
    return UTF8::strpos(UTF8::strtolower($str), UTF8::strtolower($search), $offset);
}
开发者ID:Qnatz,项目名称:starter-public-edition-4,代码行数:10,代码来源:stripos.php


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