PHP codeigniter变量未传递到视图
我正在传递标题文本以根据url中第三段的内容更改视图中的标题。第一个if语句完美地设置了标题,但它不会进入else语句,并且给了我错误,因为$headline在视图中未定义。奇怪的是,如果我使用注释的print\r语句,一切都会完美地工作,它会在视图中显示出来PHP codeigniter变量未传递到视图,php,codeigniter,Php,Codeigniter,我正在传递标题文本以根据url中第三段的内容更改视图中的标题。第一个if语句完美地设置了标题,但它不会进入else语句,并且给了我错误,因为$headline在视图中未定义。奇怪的是,如果我使用注释的print\r语句,一切都会完美地工作,它会在视图中显示出来 我想应该是$data['headine']=“updateproductdetails”行;在else中,但我不知道为什么。在你的else语句中 function create() { $data['headline'] =" "
我想应该是$data['headine']=“updateproductdetails”行;在else中,但我不知道为什么。在你的else语句中
function create()
{
$data['headline'] =" ";
$this->load->module('site_security');
$this->site_security->_make_sure_is_admin();
$update_id = $this->uri->segment(3);
if(!is_numeric($update_id))
{
$data['headline'] = "Add New Product";
//$data['headline'] = print_r($update_id)."if";
}
else
{
$data['headine'] = "Update Product Details";
//$data['headline'] = print_r($update_id)."else";
}
$data['view_module'] = "store_products"; //passing module name
$data['view_file'] = "create"; //passing method name
$this->load->module('templates'); // loads the template module
$this->templates->admin($data); //calls the template controller method admin which loads the admin view
}
你这里有个打字错误。将标题
更改为标题
else
{
$data['headine'] = "Update Product Details";
}