本文實例講述了Yii框架函數簡單用法。分享給大家供大家參考,具體如下:
1.redict
return $this->redirect(['login']);
redict其實是對于以下的封裝 等同于
$response=Yii::app->response();
$response->headers->add('location','www.baidu.com');
2.save
第一個參數是執行驗證,第二個參數是指的那個字段(空的話 就保存全部)
如果是一個兩個的話 必須知名屬性
* @param bool $runValidation whether to perform validation (calling [[validate()]])
* before saving the record. Defaults to `true`. If the validation fails, the record
* will not be saved to the database and this method will return `false`.
* @param array $attributeNames list of attribute names that need to be saved. Defaults to null,
* meaning all attributes that are loaded from DB will be saved.
* @return bool whether the saving succeeded (i.e. no validation errors occurred).
*/
public function save($runValidation = true, $attributeNames = null)
3.Yii前面加一個\代表的全局
4.as
一個類文件中重復可以使用as 起一個別名
5.設置布局文件

6.classname

order::classname
---表示的order的AR類的所有的屬性
更多關于Yii相關內容感興趣的讀者可查看本站專題:《Yii框架入門及常用技巧總結》、《php優秀開發框架總結》、《smarty模板入門基礎教程》、《php面向對象程序設計入門教程》、《php字符串(string)用法總結》、《php+mysql數據庫操作入門教程》及《php常見數據庫操作技巧匯總》
希望本文所述對大家基于Yii框架的PHP程序設計有所幫助。
您可能感興趣的文章:- Yii2中添加全局函數的方法分析
- Yii全局函數用法示例
- 深入淺析yii2-gii自定義模板的方法
- yii2高級應用之自定義組件實現全局使用圖片上傳功能的方法
- Yii2實現自定義獨立驗證器的方法
- Yii2框架自定義驗證規則操作示例
- Yii框架自定義數據庫操作組件示例
- YII框架實現自定義第三方擴展操作示例
- yii2.0之GridView自定義按鈕和鏈接用法
- yii2中的rules 自定義驗證規則詳解
- YII2框架自定義全局函數的實現方法小結