阿江
- 阿江 2017-09-18 已签到连续签到1天,获得了5个金钱
- 阿江 发布了话题[vim]左右字符交换,上下两行交换
public function prevCaptcha($attribute, $params) { $captcha = $this->createCaptchaAction(); $value = $this->vcode; $valid = !is_array($value) && $captcha->validate($value, $this->caseSensitive); if (!$valid) { $this->addError($attribute, ErrorCode::ERROR_VCODE_NOT_MATCH); } } public function createCaptchaAction() { $ca = Yii::$app->createController($this->captchaAction); return $this->captchaAction; if ($ca !== false) { /* @var $controller \yii\base\Controller */ list($controller, $actionID) = $ca; $action = $controller->createAction($actionID); $action->regenerateAfterValidation = false; if ($action !== null) { return $action; } } throw new InvalidConfigException('Invalid CAPTCHA action ID: ' . $this->captchaAction); }
上面是重写的验证方法,总在下面这一步报错,有什么解决办法吗
$ca = Yii::$app->createController($this->captchaAction);
$this->captchaAction = 'api/article/captcha';报的什么错?
- 阿江 回答了问题 CentOS7 下PHP的扩展ext文件夹没有
你在/etc/php.d目录下看到mysql.ini文件了吗?有这个文件就可以加载mysql.so
- 阿江 回答了问题 CentOS7 下PHP的扩展ext文件夹没有
找不到mysql扩展的问题,你运行下面这条命令,重启web服务应该就可以了:
[root@localhost php.d]# echo "extension=mysql.so">/etc/php.d/mysql.ini
- 阿江 回答了问题 CentOS7 下PHP的扩展ext文件夹没有
嗯,linux下是moudles,和windows下不一样,只有windows下才是ext。
- 阿江 回答了问题 CentOS7 下PHP的扩展ext文件夹没有
centos中的扩展文件(ext)后缀是*.so
在/etc/php.ini文件中要指定扩展文件(ext)所在目录:
extension_dir="/usr/lib64/php/moudules" - 阿江 回答了问题 CentOS7 下PHP的扩展ext文件夹没有
扩展模块都在/usr/lib64/php/moudules目录下。
多说一句,扩展模块的配置文件一般都在/etc/php.d目录下。你可以去看看。 - 阿江 2017-08-10 已签到连续签到1天,获得了5个金钱
- 阿江 回答了问题 请问独立验证器支持客户端验证该怎么写呢?
//实例:客户端验证器
文件位置:
\advanced\frontend\components\validators\StatusValidator.php<?php namespace frontend\components\validators; use yii\validators\Validator; use frontend\models\Validator as v; class StatusValidator extends Validator{ public function init(){ parent::init(); $this->message = '无效状态'; } public function validateAttribute($model, $attribute){ $value = $model->$attribute; if(!in_array($value,v::status())){ $model->addError($attribute, $this->message); } } public function clientValidateAttribute($model, $attribute, $view){ /* 预定义的变量(可直接在JavaScript中引用): attribute:正在被验证的属性名称 value:正在被验证的值 messages:一个数组,记录了与输入项对应的验证错误信息 deferred:一个数组,可以推入的推迟数组 */ $statuses = json_encode(v::status()); $message = json_encode($this->message, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); return <<<JS if ($.inArray(value, $statuses) === -1) { messages.push($message); } JS; } }
文件位置:
\advanced\frontend\views\post\validator.php$form = ActiveForm::begin([ 'enableClientValidation'=>true, ]); <?= $form->field($model, 'selectedDefault')->textInput(); ?>
文件位置:
\advanced\frontend\models\Validator.php<? public function rules(){ return [ ['selectedDefault',StatusValidator::className()], ]; } public static function status(){ return ['ok','active','offline','online']; } <?