# 字符串助手函數
### [](https://octobercms.com/docs/services/helpers#strings)弦樂
#### [](https://octobercms.com/docs/services/helpers#method-camel-case)`camel_case()`
該`camel_case`函數將給定的字符串轉換為`camelCase`:
~~~
$camel = camel_case('foo_bar');
// fooBar
~~~
#### [](https://octobercms.com/docs/services/helpers#method-class-basename)`class_basename()`
該`class_basename`收益與類的命名空間中的給定類的類名稱中刪除:
~~~
$class = class_basename('Foo\Bar\Baz');
// Baz
~~~
#### [](https://octobercms.com/docs/services/helpers#method-e)`e()`
該`e`函數`htmlentities`在給定的字符串上運行:
~~~
echo e('<html>foo</html>');
// <html>foo</html>
~~~
#### [](https://octobercms.com/docs/services/helpers#method-ends-with)`ends_with()`
該`ends_with`函數確定給定的字符串是否以給定的值結尾:
~~~
$value = ends_with('This is my name', 'name');
// true
~~~
#### [](https://octobercms.com/docs/services/helpers#method-snake-case)`snake_case()`
該`snake_case`函數將給定的字符串轉換為`snake_case`:
~~~
$snake = snake_case('fooBar');
// foo_bar
~~~
#### [](https://octobercms.com/docs/services/helpers#method-str-limit)`str_limit()`
該`str_limit`函數限制字符串中的字符數。該函數將字符串作為第一個參數,并將最大字符數作為第二個參數:
~~~
$value = str_limit('The CMS platform that gets back to basics.', 6);
// The CMS...
~~~
#### [](https://octobercms.com/docs/services/helpers#method-starts-with)`starts_with()`
該`starts_with`函數確定給定的字符串是否以給定的值開頭:
~~~
$value = starts_with('The cow goes moo', 'The');
// true
~~~
#### [](https://octobercms.com/docs/services/helpers#method-str-contains)`str_contains()`
該`str_contains`函數確定給定的字符串是否包含給定的值:
~~~
$value = str_contains('The bird goes tweet', 'bird');
// true
~~~
#### [](https://octobercms.com/docs/services/helpers#method-str-finish)`str_finish()`
該`str_finish`函數將給定值的單個實例添加到字符串中:
~~~
$string = str_finish('this/string', '/');
// this/string/
~~~
#### [](https://octobercms.com/docs/services/helpers#method-str-is)`str_is()`
該`str_is`函數確定給定的字符串是否匹配給定的模式。星號可用于表示通配符:
~~~
$value = str_is('foo*', 'foobar');
// true
$value = str_is('baz*', 'foobar');
// false
~~~
#### [](https://octobercms.com/docs/services/helpers#method-str-plural)`str_plural()`
該`str_plural`函數將字符串轉換為其復數形式。此功能目前僅支持英語:
~~~
$plural = str_plural('car');
// cars
$plural = str_plural('child');
// children
~~~
#### [](https://octobercms.com/docs/services/helpers#method-str-random)`str_random()`
該`str_random`函數生成指定長度的隨機字符串:
~~~
$string = str_random(40);
~~~
#### [](https://octobercms.com/docs/services/helpers#method-str-singular)`str_singular()`
該`str_singular`函數將字符串轉換為單數形式。此功能目前僅支持英語:
~~~
$singular = str_singular('cars');
// car
~~~
#### [](https://octobercms.com/docs/services/helpers#method-str-slug)`str_slug()`
該`str_slug`函數從給定的字符串生成URL友好的“ slug”:
~~~
$title = str_slug("October CMS", "-");
// october-cms
~~~
#### [](https://octobercms.com/docs/services/helpers#method-studly-case)`studly_case()`
該`studly_case`函數將給定的字符串轉換為`StudlyCase`:
~~~
$value = studly_case('foo_bar');
// FooBar
~~~
#### [](https://octobercms.com/docs/services/helpers#method-trans)`trans()`
該`trans`函數使用您的[本地化文件](https://octobercms.com/docs/plugin/localization)翻譯給定的語言行:
~~~
echo trans('validation.required'):
~~~
#### [](https://octobercms.com/docs/services/helpers#method-trans-choice)`trans_choice()`
該`trans_choice`函數使用拐點翻譯給定的語言行:
~~~
$value = trans_choice('foo.bar', $count);
~~~
- 基本說明
- 基本操作
- October cms 安裝
- 后臺控制器路徑
- 圖標
- 獲取安裝網上的插件/主題
- 插件構造器使用
- 定時任務
- October后臺控制器
- vscode編輯器
- ajax操作
- 使用
- ajax更新組件
- ajax屬性API
- JavaScript API
- ajax綜合使用
- 主題
- 多語言主題
- 安裝市場主題
- 主題程序處理
- 主題
- 頁面
- 部件
- 布局
- 內容
- 組件
- 媒體
- 主題表單操作
- 表單使用
- 表單后端程序處理
- 插件
- 自定義插件
- 插件說明
- 插件導航條
- 插件數據庫設置
- 插件的設置管理
- 插件的配置文件config
- 組件
- app服務
- app容器
- 擴展行為
- 緩存
- Collection類
- Lazy Collections
- Collection方法
- 助手函數
- 數組助手函數
- 路徑助手函數
- 玄樂助手函數
- 其他助手函數
- 錯誤與記錄
- 事件處理
- HTML頁面
- 文件與目錄操作
- 散列和加密
- 郵件
- 郵件內容
- 郵件發送
- 分頁
- 模板解析器
- 動態解析器語法
- 隊列消息
- 請求與輸入
- 響應
- 視圖
- 路由器
- 配置
- 驗證操作
- 處理錯誤消息
- 錯誤消息與視圖
- 可用的驗證規則
- 有條件的驗證規則
- 驗證數組
- 錯誤消息
- 自定義驗證規則
- 模型操作
- 定義模型與其屬性
- 檢索模型
- 插入與更新
- 刪除模型
- 查詢范圍
- 事件操作
- 關聯操作
- 定義關系
- 關系類型
- 多肽關系
- 關系查詢
- 渴望加載
- 插入模型
- 數據庫操作
- 基本用法
- 數據表結構
- 查詢連貫操作
- 結果檢索
- select子句
- 插入更新
- where子句
- 排序,分組,限制和偏移
- 文件附件
- Collection操作
- 屬性操作
- 系列化json
- 數據庫屬性
- 數據庫行為
- 控制器
- 后臺控制器定義
- 后臺頁面
- 后臺組件
- 后臺表單
- 表單組件
- 表單視圖
- 表單行為
- 后臺列表
- 列表行為
- 列表過濾器
- 可用列類型
- 關系行為
- 關系行為類型
- 擴展關系行為
- 列表排序操作
- 導入導出操作
- 用于與權限
- corlate模板修改
- 修改頂部導航
- laravel問題
- 控制器不存在
- 控制器
- 路由組
- laravel筆記
- laravel 安裝
- 偽靜態配置
- 依賴注入 & 控制器
- 中間件
- 路由文件
- 視圖