我试图将变量形式的函数传递给codeigniter中同一控制器中的另一个函数。我用下面的代码如何将变量从一个函数传递到同一控制器中的其他函数
redirect('fornt/fullcommunity',$project_encode_id);
这里fornt是控制器的名字, 全社会的控制器 $ project_encode_id里面的功能是通过 的变量,但它不工作
我试图将变量形式的函数传递给codeigniter中同一控制器中的另一个函数。我用下面的代码如何将变量从一个函数传递到同一控制器中的其他函数
redirect('fornt/fullcommunity',$project_encode_id);
这里fornt是控制器的名字, 全社会的控制器 $ project_encode_id里面的功能是通过 的变量,但它不工作
firsst你需要添加你的控制器代码。 然后,如果bouth方法是在同一个控制器只需要做到这一点
class Your_controller extends CI_Controller{
public function method1(){
$variable_form = $this->input->post('form_variable', TRUE);
//calling second method
$response = $this->_method2($variable_form);
}
private function _method2 ($str){
return 'do somthing -> ' . $str;
}
}
在你的情况我会用下面的替换重定向一句: $这个 - >负载>视图(“funLoadView ”,$ requiredVarForView); 第一个参数是控制器中的函数,第二个参数是需要包含的数据(可能的数组)。 这两个函数都在同一个控制器类上,所以你不需要包含任何对控制器类名称的引用
它不清楚你在这里问什么,但它听起来像你可以简单地执行'$ this-> othermethod ($ project_encode_id);'所以如果这是错误的,你将不得不更好地解释你想要做什么 – RiggsFolly
你想在这里实际做什么?重定向到控制器还是你想调用其他方法? – Rehmat