for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Created by rozbo at 2017/3/18 下午9:03
*/
namespace puck\tools;
class Str {
* 判断一个字符串是否包含于另一个字符中
*
* @param string $haystack
* @param string|array $needles
* @return bool
public static function contains($haystack, $needles)
{
foreach ((array) $needles as $needle) {
if ($needle != '' && mb_strpos($haystack, $needle) !== false) {
return true;
}
return false;
* 判断一个字符串是否以给定字符串开始
public static function startsWith($haystack, $needles)
if ($needle != '' && substr($haystack, 0, strlen($needle)) === (string) $needle) {
* 判断一个字符串是否以给定字符串结尾
public static function endsWith($haystack, $needles)
if (substr($haystack, -strlen($needle)) === (string) $needle) {