Php 检查真正返回的表单codeigniter模型
我想要一个简单但正确的方法来检查codeigniter模型是否返回了true或false 所以 如果我的模型返回true,我可以在控制器中执行此操作吗Php 检查真正返回的表单codeigniter模型,php,codeigniter,Php,Codeigniter,我想要一个简单但正确的方法来检查codeigniter模型是否返回了true或false 所以 如果我的模型返回true,我可以在控制器中执行此操作吗 if($variable = $this->ci_model->model_method($user_id)){ // true, was returned do something } 或者我必须专门测试是否返回了true,以及如何才能这样做?这样做: $variable = $this->ci_model->mo
if($variable = $this->ci_model->model_method($user_id)){
// true, was returned do something
}
或者我必须专门测试是否返回了true,以及如何才能这样做?这样做:
$variable = $this->ci_model->model_method($user_id);
if(!empty($variable))
{
return true
}
else
{
return false;
}
if($this->ci_model->model_method($user_id))
{
return true
}
else
{
return false;
}
或者您可以这样做:
$variable = $this->ci_model->model_method($user_id);
if(!empty($variable))
{
return true
}
else
{
return false;
}
if($this->ci_model->model_method($user_id))
{
return true
}
else
{
return false;
}
这样做:
$variable = $this->ci_model->model_method($user_id);
if(!empty($variable))
{
return true
}
else
{
return false;
}
if($this->ci_model->model_method($user_id))
{
return true
}
else
{
return false;
}
或者您可以这样做:
$variable = $this->ci_model->model_method($user_id);
if(!empty($variable))
{
return true
}
else
{
return false;
}
if($this->ci_model->model_method($user_id))
{
return true
}
else
{
return false;
}
如果返回值为真,则无需执行特殊操作。你也可以使用
if($this->ci\u model->model\u method($user\u id))
所以如果我想检查false,我可以这样做if(!$this->ci\u model->model\u method($user\u id))
正确!!!如果真的返回,则无需执行特殊操作。你也可以使用if($this->ci\u model->model\u method($user\u id))
所以如果我想检查false,我可以这样做if(!$this->ci\u model->model\u method($user\u id))
正确!!!着手