本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
示例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 {
示例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);
}