草庐IT

static_check

全部标签

php - CodeIgniter - 无法访问与您的字段名称密码对应的错误消息。(pword_check)

我是codeIgniter的新手,刚开始就卡住了。我正在使用HMVC扩展,在验证时出现以下错误:无法访问与您的字段名称密码相对应的错误消息。(pword_check)任何帮助将不胜感激代码:publicfunctionsubmit(){$this->load->library('form_validation');$this->form_validation->set_rules('username','Username','required|max_length[30]|xss_clean');$this->form_validation->set_rules('pword','Pa

PHP 7 fatal error :static::class 不能用于编译时类名解析

当前的Travis-CIPHP7构建在执行以下代码时抛出以下错误:PHP7Fatalerror:static::classcannotbeusedforcompile-timeclassnameresolutiontraitEloquentValidatingTrait{//Somedeclarationsskipped/***Eloquentwillcallthisonmodelboot*/publicstaticfunctionbootEloquentValidatingTrait(){//CallingModel::saving()andaskingittoexecuteasse

php - 错误 : Unable to find the controller for path "/login_check". 路由配置错误。 (LexikJWTAuthentication)

描述当我对在http://localhost:8000/api/admin/login_check上运行的symfony服务器执行正常请求时,它返回所需的jwttoken.但是,当我使用功能测试(使用./bin/phpunit)执行此操作时,出现以下错误:Error:Unabletofindthecontrollerforpath\"/api/admin/login_check\".Therouteiswronglyconfigured.我还浏览了functionaltestdocs.BugReproduced不要犹豫,克隆或fork此项目进行测试。README.md解释了安装步骤。我

php - JSON_NUMERIC_CHECK 和电话号码

我们的PHPAPI使用启用了JSON_NUMERIC_CHECK的json_encode输出结果,这对财务数据、二进制值等很重要。但我们最近引入了一个电话号码字段,它在转换时从数字开头删除零它作为一个整数。我试图在值进入json_encode之前强制输入“(string)”类型,但看起来函数正在覆盖它。例如:$output=array('is_bool'=>1,'total_amount'=>'431.65','phone_number'=>(string)'0272561313');echojson_encode($output,JSON_NUMERIC_CHECK);产生:{"is

php - Zend_Form : Element should only be required if a checkbox is checked

我有一个表单,用户可以在其中选中“创建新地址”复选框,然后可以在同一个表单中填写这个新地址的字段。现在我只想在复选框被选中时验证这个新地址的字段。否则,应忽略它们。我如何使用Zend_Form和Zend_Validate来做到这一点?谢谢! 最佳答案 我认为最好、更正确的方法是创建自定义验证器。您可以通过两种不同的方式执行此验证器,一种是使用传递给方法isValid的第二个参数$context,即当前正在验证的表单,或者注入(inject)需要检查验证的Checkbox元素在构造函数中发生。我更喜欢最后一个:'Elementrequ

php - preg_match : check birthday format (dd/mm/yyyy)

如何创建检查生日输入以匹配像这样的dd/mm/yyyy格式的表达式?以下是我到目前为止得出的结果,但如果我输入99/99/9999,它也会用这个!if(!preg_match("/[0-9]{2}\/[0-9]{2}\/[0-9]{4}/",$cnt_birthday)){$error=true;echo'';}我怎样才能确保dd只有01到31,mm只有01到12?但我确定如何限制yyyy...我认为理论上的9999应该是可以接受的...如果您有更好的主意,请告诉我!谢谢,刘 最佳答案 基于Tim的checkdate基于解决方案:使

php - "Static methods are death to testability"- 替代构造函数的替代品?

据说"staticmethodsaredeathtotestability"。如果是这样,下面的可行替代模式是什么?classUser{private$phone,$status='default',$created,$modified;publicfunction__construct($phone){$this->phone=$phone;$this->created=newDateTime;$this->modified=newDateTime;}publicstaticfunctiongetByPhone(PDO$pdo,$phone){$stmt=$pdo->prepare(

php - PHP 5.2 中的类继承 : Overriding static variable in extension class?

我需要能够在从基类扩展基类的类中使用静态变量集。考虑一下:classAnimal{publicstatic$color='black';publicstaticfunctionget_color(){returnself::$color;}}classDogextendsAnimal{publicstatic$color='brown';}echoAnimal::get_color();//prints'black'echoDog::get_color();//alsoprints'black'这在PHP5.3.x中非常有效(Dog::get_color()打印'brown'),因为它

android - ActivityInstrumentationTestCase2和static final : fields become null after first test的使用

这看起来真的像是发生了一些魔法,我很想知道为什么会这样:)这是我的单元测试:publicclassSelectThemeActivityTestextendsActivityInstrumentationTestCase2{privatefinalstaticint[]STATIC_ARRAY={0,1,2};publicSelectThemeActivityTest(){super("com.the7art.simplewallpaper",SelectThemeActivity.class);}@OverrideprotectedvoidsetUp()throwsException

安卓开发 : Where to put static Key/Value Pairs?

我有一个静态键/值对列表,我需要将它们包含在我的项目中,如下所示:givenName:FirstNamesn:LastNamemail:Email...snip...我应该把它放在Android项目的什么地方?谢谢埃里克 最佳答案 您需要一个保存在res/values/strings.xml的XML文件:FirstNameLastNameEmail以下是您可以从其他xml访问值的方法:或者这是从Java代码访问值的方法:Stringstring=getString(R.string.givenName);Log.d("Test",s