當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Utf8::stristr方法代碼示例

本文整理匯總了PHP中Patchwork\Utf8::stristr方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utf8::stristr方法的具體用法?PHP Utf8::stristr怎麽用?PHP Utf8::stristr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Patchwork\Utf8的用法示例。


在下文中一共展示了Utf8::stristr方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: api_stristr

/**
 * Finds first occurrence of a string within another, case insensitive.
 * @param string $haystack					The string from which to get the first occurrence.
 * @param mixed $needle						The string to be found.
 * @param bool $before_needle (optional)	Determines which portion of $haystack this function returns. The default value is FALSE.
 * @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 portion of $haystack, or FALSE if $needle is not found.
 * Notes:
 * If $needle is not a string, it is converted to an integer and applied as the ordinal value (codepoint if the encoding is UTF-8) of a character.
 * If $before_needle is set to TRUE, the function returns all of $haystack from the beginning to the first occurrence of $needle.
 * If $before_needle is set to FALSE, the function returns all of $haystack from the first occurrence of $needle to the end.
 * This function is aimed at replacing the functions stristr() and mb_stristr() for human-language strings.
 * @link http://php.net/manual/en/function.stristr
 * @link http://php.net/manual/en/function.mb-stristr
 */
function api_stristr($haystack, $needle, $before_needle = false, $encoding = null)
{
    return Utf8::stristr($haystack, $needle, $before_needle);
}
開發者ID:KRCM13,項目名稱:chamilo-lms,代碼行數:19,代碼來源:internationalization.lib.php

示例2: testStrstr

 /**
  * @covers Patchwork\Utf8::strstr
  * @covers Patchwork\Utf8::stristr
  * @covers Patchwork\Utf8::strrchr
  * @covers Patchwork\Utf8::strrichr
  */
 function testStrstr()
 {
     $this->assertSame('éjàdéjà', u::strstr('déjàdéjà', 'é'));
     $this->assertSame('ÉJÀDÉJÀ', u::stristr('DÉJÀDÉJÀ', 'é'));
     $this->assertSame('ςσb', u::stristr('aςσb', 'ΣΣ'));
     $this->assertSame('éjà', u::strrchr('déjàdéjà', 'é'));
     $this->assertSame('ÉJÀ', u::strrichr('DÉJÀDÉJÀ', 'é'));
     $this->assertSame('d', u::strstr('déjàdéjà', 'é', true));
     $this->assertSame('D', u::stristr('DÉJÀDÉJÀ', 'é', true));
     $this->assertSame('a', u::stristr('aςσb', 'ΣΣ', true));
     $this->assertSame('déjàd', u::strrchr('déjàdéjà', 'é', true));
     $this->assertSame('DÉJÀD', u::strrichr('DÉJÀDÉJÀ', 'é', true));
     $this->assertSame('Paris', u::stristr('der Straße nach Paris', 'Paris'));
 }
開發者ID:nicolas-grekas,項目名稱:Patchwork-sandbox,代碼行數:20,代碼來源:Utf8Test.php

示例3: test_linefeed_both

 public function test_linefeed_both()
 {
     $str = "iñtërn\nâtiônàlizætiøn";
     $search = "N\nÂT";
     $this->assertEquals("n\nâtiônàlizætiøn", u::stristr($str, $search));
 }
開發者ID:nicolas-grekas,項目名稱:Patchwork-sandbox,代碼行數:6,代碼來源:Utf8StristrTest.php


注:本文中的Patchwork\Utf8::stristr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。