企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
# 字符串 ## camel\_case 把给定的字串转换成 驼峰式命名。 ``` $camel = camel_case('foo_bar'); // fooBar ``` ## class\_basename 取得给定类的类名称,不含任何命名空间的名称。 ``` $class = class_basename('Foo\Bar\Baz'); // Baz ``` ## e 对给定字串执行 htmlentities,并支持 UTF-8。 `$entities = e('<html>foo</html>');` ## ends\_with 判断句子结尾是否有给定的字串。 `$value = ends_with('This is my name', 'name');` ## snake\_case 把给定的字串转换成 蛇形命名。 ``` $snake = snake_case('fooBar'); // foo_bar ``` ## str\_limit 限制字串的字符数量。 `str_limit($value, $limit = 100, $end = '...')` 例子: ``` $value = str_limit('The PHP framework for web artisans.', 7); // The PHP... ``` ## starts\_with 判断句子是否开头有给定的字串。 `$value = starts_with('This is my name', 'This');` ## str\_contains 判断句子是否有给定的字串。 `$value = str_contains('This is my name', 'my');` ## str\_finish 加一个给定字串到句子结尾。多余一个的给定字串则移除。 ``` $string = str_finish('this/string', '/'); // this/string/ ``` ## str\_is 判断字串是否符合给定的模式。星号可以用来当作通配符。 `$value = str_is('foo*', 'foobar');` ## str\_plural 把字串转换成它的多数形态 (只有英文)。 `$plural = str_plural('car');` ## str\_random 产生给定长度的随机字串。 `$string = str_random(40);` ## str\_singular 把字串转换成它的单数形态 (只有英文)。 `$singular = str_singular('cars');` ## str\_slug 从给定字串产生一个对网址友善的「slug」。 `str_slug($title, $separator);` 例子: ``` $title = str_slug("Laravel 5 Framework", "-"); // laravel-5-framework ``` ## studly\_case 把给定字串转换成 首字大写命名。 ``` $value = studly_case('foo_bar'); // FooBar ``` ## trans 翻译给定的语句。等同 Lang::get。 `$value = trans('validation.required'):` ## trans\_choice 随着词形变化翻译给定的语句。等同 Lang::choice。 `$value = trans_choice('foo.bar', $count);`