當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。