Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/239.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 验证码不显示任何图像_Php_Yii_Captcha - Fatal编程技术网

Php 验证码不显示任何图像

Php 验证码不显示任何图像,php,yii,captcha,Php,Yii,Captcha,在我的应用程序中使用多个布局后,Cpatcha不会显示任何图像:( 这是我的密码 控制器: public function actions() { return array( // captcha action renders the CAPTCHA image displayed on the contact page 'captcha'=>ar

在我的应用程序中使用多个布局后,Cpatcha不会显示任何图像:(

这是我的密码

控制器:

public function actions()
        {
                return array(
                        // captcha action renders the CAPTCHA image displayed on the contact page
                        'captcha'=>array(
                                'class'=>'CCaptchaAction',
                                'backColor'=>0xFFFFFF,
                        ),
                        // page action renders "static" pages stored under 'protected/views/site/pages'
                        // They can be accessed via: index.php?r=site/page&view=FileName
                        'page'=>array(
                                'class'=>'CViewAction',
                        ),
                );
        }
型号:

public function rules()
{
        return array(
                array('email, password', 'required','message'=>'-- {attribute}  '),

                array('password', 'authenticate'),

                // verifyCode needs to be entered correctly
        array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements(),'message'=>' {attribute}  Error '),

);

}
查看呼叫小部件

...
        <div>
                <?php $this->widget('CCaptcha'); ?>
                <?php echo $form->textField($model,'verifyCode'); ?>
                </div>
...
。。。
...
我在请求记录器上测试了它,它发送和接收请求。


提前感谢

如果您正在使用访问控制,很可能您没有为验证码操作设置
accessRules
。您需要添加该操作,例如:

public function accessRules() {
    return array(
        array('allow', // all users
            'actions' => ("captcha"),
            'users' => array('*'),
        ),
        array('allow', // authenticated users
            'actions' => ("captcha"),
            'users' => array('@'),
        ),
        array('deny', // deny all users
            'users' => array('*'),
        ),
    );
}

如果您正在使用访问控制,很可能您没有为验证码操作设置
accessRules
。您需要添加该操作,例如:

public function accessRules() {
    return array(
        array('allow', // all users
            'actions' => ("captcha"),
            'users' => array('*'),
        ),
        array('allow', // authenticated users
            'actions' => ("captcha"),
            'users' => array('@'),
        ),
        array('deny', // deny all users
            'users' => array('*'),
        ),
    );
}

我通过添加删除Bom功能修复了它

ob_start('My_OB');
function My_OB($str, $flags)
{
    //remove UTF-8 BOM
    $str = preg_replace("/\xef\xbb\xbf/","",$str);

    return $str;
}

我猜问题出在页面编码上。

我通过添加删除Bom功能修复了它

ob_start('My_OB');
function My_OB($str, $flags)
{
    //remove UTF-8 BOM
    $str = preg_replace("/\xef\xbb\xbf/","",$str);

    return $str;
}

我想问题出在页面编码上。

既然您确信captcha不会只在添加多个版面后才显示,请为多个版面添加代码,可能是因为有错误导致了这一点,尽管这不太可能。您检查了css吗?我想现在多个样式与此问题无关?!我想是吧hing elseok确实要测试这一点,尝试使用多个布局,而不使用。看看这两种布局是否都失败。另外,你能从视图中显示你的整个验证码行吗,你正在进行检查要求检查吗?请在yii论坛中检查我的问题和答案,嗯,因此似乎某处可能有一些空白,请检查你复制的文件ted,这里肯定有错误。既然你确定captcha不只是在添加多个版面后才显示,那么为多个版面添加代码,可能是因为有一些错误导致了这一点,尽管这不太可能。你检查了你的css吗?我想现在多个样式与这个问题无关?!!我想还有其他一些问题没有解决可以肯定的是,尝试使用多个布局,而不使用。看看这两种布局是否都失败。另外,您可以从视图中显示您的整个验证码行,您正在进行检查要求检查吗?请检查我在yii论坛中的问题和答案,嗯,因此似乎某处可能有一些空白,检查您复制粘贴的文件,确定这里有些错误。