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


PHP Utf8::strstr方法代码示例

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


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

示例1: api_strstr

/**
 * Finds first occurrence of a string within another.
 * @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 strstr() and mb_strstr() for human-language strings.
 * @link http://php.net/manual/en/function.strstr
 * @link http://php.net/manual/en/function.mb-strstr
 */
function api_strstr($haystack, $needle, $before_needle = false, $encoding = null)
{
    return Utf8::strstr($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: utf8_strstr

/**
 * Find the first occurrence of a string in another string
 *
 * @param string $haystack
 * @param string $needle
 *
 * @return string
 *
 * @deprecated Deprecated since Contao 4.0, to be removed in Contao 5.0.
 *             Use Patchwork\Utf8::strstr() instead.
 */
function utf8_strstr($haystack, $needle)
{
    @trigger_error('Using utf8_strstr() has been deprecated and will no longer work in Contao 5.0. Use Patchwork\\Utf8::strstr() instead.', E_USER_DEPRECATED);
    return Utf8::strstr($haystack, $needle);
}
开发者ID:contao,项目名称:core-bundle,代码行数:16,代码来源:functions.php


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