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
}
我正在传递标题文本以根据 url 中第三段的内容更改 View 中的标题。第一个 if 语句完美地设置了标题,但它不会进入 else 语句并且给我错误,因为 $headline 在 View 中未定义。奇怪的是,如果我使用注释的 print_r 语句,一切都会完美地显示在 View 中。
我认为它必须是行 $data['headine'] = "Update Product Details";在其他方面,但我不知道为什么。
最佳答案
在你的 else 语句中,
else
{
$data['headine'] = "Update Product Details";
}
这里有错别字。将 headine
更改为 headline
。
关于PHP codeigniter 变量未传递给 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40814100/