上一页 1 2 3 4 5 6 ··· 36 下一页
摘要: yii2 session 开启和关闭Sessions $session = Yii::$app->session; // 检查session是否开启 if ($session->isActive) ... // 开启session $session->open(); // 关闭session $se 阅读全文
posted @ 2024-03-30 14:54 胡勇健 阅读(77) 评论(0) 推荐(0)
摘要: Yii2-助手类(formatter) 示例 echo \Yii::$app->formatter->asDatetime(time(),'Y-M-d H:i:s'); //2023-05-12 12:32:32 echo \Yii::$app->formatter->asRelativeTime( 阅读全文
posted @ 2024-03-30 14:53 胡勇健 阅读(30) 评论(0) 推荐(0)
摘要: Yii2 ArrayHelper助手 数组助手类 ArrayHelper Yii 数组助手类提供了额外的静态方法,让你更高效的处理数组。 模型转数组 $model = Country::findOne(['code'=>'BR']); ArrayHelper::toArray($model); // 阅读全文
posted @ 2024-03-30 14:52 胡勇健 阅读(197) 评论(0) 推荐(0)
摘要: Yii2-助手类(Html) 引入命名空间 use yii\helpers\Html; 使用 <?php //【一】表单:Html::beginForm(提交地址,提交方法,属性数组);?> <?=Html::beginForm('','post',['id'=>'form','class'=>'f 阅读全文
posted @ 2024-03-30 14:50 胡勇健 阅读(52) 评论(0) 推荐(0)
摘要: Yii2-助手(StringHelper) 截断字符串 echo StringHelper::truncate('中文截断字符',4); //'中文截断...' 字符串转数组 StringHelper::explode('this is string',' '); //[ 0 => 'this' 1 阅读全文
posted @ 2024-03-30 14:49 胡勇健 阅读(30) 评论(0) 推荐(0)
摘要: yii2-分页 使用ActiveDataProvider 和 GridView controller public function actionIndex(){ $dataProvider = new ActiveDataProvider([ 'query' => ArticleClass::fi 阅读全文
posted @ 2024-03-30 14:46 胡勇健 阅读(64) 评论(0) 推荐(0)
摘要: 分页 使用ActiveDataProvider 和 GridView controller public function actionIndex(){ $dataProvider = new ActiveDataProvider([ 'query' => ArticleClass::find(), 阅读全文
posted @ 2024-03-30 14:44 胡勇健 阅读(23) 评论(0) 推荐(0)
摘要: yii2 密码和加解密 生成hash $hash = Yii::$app->getSecurity()->generatePasswordHash($password); 验证hash if (Yii::$app->getSecurity()->validatePassword($password, 阅读全文
posted @ 2024-03-30 14:43 胡勇健 阅读(135) 评论(0) 推荐(0)
摘要: yii2-用户认证 配置 yii\web\User return [ 'components' => [ 'user' => [ 'identityClass' => 'app\models\User', 'enableAutoLogin' => true, 'loginUrl' => ['user 阅读全文
posted @ 2024-03-30 14:42 胡勇健 阅读(56) 评论(0) 推荐(0)
摘要: Yii2 过滤器 过滤器AccessController AccessControl 基于一组规则提供简单的访问控制 /** * {@inheritdoc} */ public function behaviors() { return [ 'access' => [ 'class' => Acce 阅读全文
posted @ 2024-03-30 14:41 胡勇健 阅读(67) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 ··· 36 下一页