草庐IT

be_false

全部标签

php - 在 Yii 中更改错误 'cannot be blank'

关于Yii中错误信息的处理:通常,Yii已经配置了表单的验证,当其中一个必填字段没有填写时,错误信息将显示为"Blablablacannotbeblank."如何自定义该错误消息?例如,我想改成这样:"Blablablatidakbolehkosong." 最佳答案 不清楚你到底想做什么,但是假设您想使用完全不同的消息:publicfunctionrules(){returnarray(array('title,content','required','message'=>'Pleaseenteravaluefor{attribut

php - 从 __constructor 返回 false

你能从构造函数返回false吗?host=$host;$this->username=$username;$this->password=$password;$this->connection_type=$connection_type;//nowsettheconnectionintothisclassesconnection$this->connection=$this->connect();//checktheconnectionwassetelsereturnfalseif($this->connection===false){returnfalse;}}...etcetcth

PHP 可捕获 fatal error : Object of class could not be converted to string

我完全迷失在这里......在验证一些输入后,我创建了一个Message类的实例并尝试将数据插入数据库://sendmessage$message=$this->model->build('message',true);$message->insertMessage($uid,$user->user_id,$title,$message);插入的方法非常简单://insertanewmessagepublicfunctioninsertMessage($to_id,$from_id,$title,$body){$sql="INSERTINTOmessages(to_id,from_id

php - function_exists 每次都返回 false

我正在尝试检查一个函数是否存在,但我的if中总是报错我尝试这样调用函数,其中$function是函数名:if(function_exists($this->module->$function)){$this->module->$function($vars);}else{echo'no';}变量module被定义为应该调用函数的类:$this->module=$module;$this->module=new$this->module;我是不是漏掉了什么?谢谢! 最佳答案 只是可以弄清楚:使用method_exists()解决了我的

php - 为什么 isset() 总是在自定义对象上返回 FALSE

我无法理解这种行为:我的isset()检查总是在具有确定值的property上返回false!$property;}else{thrownewException('property'.$property.'doesnotexistin'.__CLASS__.'class');}}}?>当我使用以下代码从另一个类检查此变量时:isset($loggedUser->userName);//loggedUserismyinstantiationoftheUser.php它返回FALSE??但是当我在我的User.php中重载__isset()函数时,我得到了TRUE,正如我预期的那样:pub

php - CodeIgniter form_validation->run() 总是返回 false?

我是CodeIgniter的新手,我一直在尝试实现表单提交功能,但是每当我按下“提交”时,表单页面只会刷新,而数据库不会更新!$this->form_validation->run()似乎总是返回false,但我不知道为什么。controller函数如下:publicfunctionwrite_prof_review($prof_id){$this->load->model('Queries');//formstuffhere$this->load->helper('form');$this->load->library('form_validation');$data['prof_i

php - SQLSTATE[08001] : [Microsoft][ODBC Driver 13 for SQL Server]TCP Provider: No connection could be made because the target machine actively refused it

我的学说存储库代码无法运行,但我能够正常访问数据库和读取表数据。我得到这个堆栈跟踪:EntityManager->getRepository('AppBundle:Person')insrc\AppBundle\Controller\PersonViewController.php(line18)publicfunctionindexAction(Request$request){$em=$this->getDoctrine()->getManager();$repo=$em->getRepository('AppBundle:Person');$persons=$repo->find

php - 在 NetBeans 中对 false、true、null 使用小写常量

有什么方法可以将它们设置为小写的自动完成代码?它们自动以大写形式出现,我知道常量是以大写形式定义的,但我更喜欢它们的小写形式。 最佳答案 我在C:\ProgramFiles\NetBeans6.9.1\php\phpstubs\phpruntime\Core.php中找到了下一个define('LOG_PERROR',32);define('TRUE',true);define('FALSE',false);define('NULL',null);define('ZEND_THREAD_SAFE',false);define('ZE

php - Zend_Session : Session must be started before any output has been sent to the browser

我以前遇到过这个问题,但我不记得如何解决它。我已经创建了一个基本的(再简单不过了)Controller,我只是想向浏览器回显一些东西,我收到了这条消息:Fatalerror:Uncaughtexception'Zend_Session_Exception'withmessage'Sessionmustbestartedbeforeanyoutputhasbeensenttothebrowser...这是我的整个Controller。它显示“成功”,但也显示错误消息。我怎样才能使该错误消息静音,以便我可以简单地向浏览器回显一些内容?_helper->layout->disableLayo

php - FILTER_VALIDATE_BOOLEAN 的输入值为 false

我希望输入只接受“真”或“假”,所以我尝试使用FILTER_VALIDATE_BOOLEAN来做到这一点,if(!filter_var('false',FILTER_VALIDATE_BOOLEAN)){$error=true;echo'error';}它回显了错误消息,但它不应该。我怎样才能让它正确? 最佳答案 看看手册http://www.php.net/manual/en/filter.filters.validate.php您的语法/用法是正确的。filter_var('false',FILTER_VALIDATE_BOOL