本文整理汇总了PHP中Patchwork\Utf8::strpos方法的典型用法代码示例。如果您正苦于以下问题:PHP Utf8::strpos方法的具体用法?PHP Utf8::strpos怎么用?PHP Utf8::strpos使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Patchwork\Utf8
的用法示例。
在下文中一共展示了Utf8::strpos方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: api_strpos
/**
* Finds position of first occurrence of a string within another.
* @param string $haystack The string from which to get the position of the first occurrence.
* @param string $needle The string to be found.
* @param int $offset (optional) The position in $haystack to start searching from. If it is omitted, searching starts from the beginning.
* @param string $encoding (optional) The used internally by this function character encoding. If it is omitted, the platform character set will be used by default.
* @return mixed Returns the numeric position of the first occurrence of $needle in the $haystack, or FALSE if $needle is not found.
* Note: The first character's position is 0, the second character position is 1, and so on.
* This function is aimed at replacing the functions strpos() and mb_strpos() for human-language strings.
* @link http://php.net/manual/en/function.strpos
* @link http://php.net/manual/en/function.mb-strpos
*/
function api_strpos($haystack, $needle, $offset = 0, $encoding = null)
{
return Utf8::strpos($haystack, $needle, $offset);
}
示例2: testStrpos
/**
* @covers Patchwork\Utf8::strpos
* @covers Patchwork\Utf8::stripos
* @covers Patchwork\Utf8::strrpos
* @covers Patchwork\Utf8::strripos
*/
function testStrpos()
{
$this->assertSame(false, u::strpos('abc', ''));
$this->assertSame(false, u::strpos('abc', 'd'));
$this->assertSame(false, u::strpos('abc', 'a', 3));
$this->assertSame(0, u::strpos('abc', 'a', -1));
$this->assertSame(1, u::strpos('한국어', '국'));
$this->assertSame(3, u::stripos('DÉJÀ', 'à'));
$this->assertSame(1, u::stripos('aςσb', 'ΣΣ'));
$this->assertSame(false, u::strrpos('한국어', ''));
$this->assertSame(1, u::strrpos('한국어', '국'));
$this->assertSame(3, u::strripos('DÉJÀ', 'à'));
$this->assertSame(1, u::strripos('aςσb', 'ΣΣ'));
$this->assertSame(16, u::stripos('der Straße nach Paris', 'Paris'));
}
示例3: utf8_strpos
/**
* Find the position of the first occurence of a string in another string
*
* @param string $haystack
* @param string $needle
* @param integer $offset
*
* @return integer
*
* @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
* Use Patchwork\Utf8::strpos instead.
*/
function utf8_strpos($haystack, $needle, $offset = 0)
{
@trigger_error('Using utf8_strpos() has been deprecated and will no longer work in Contao 5.0. Use Patchwork\\Utf8::strpos() instead.', E_USER_DEPRECATED);
return Utf8::strpos($haystack, $needle, $offset);
}