Codeigniter: Passing data from controller to view

后端 未结 13 2153
忘了有多久
忘了有多久 2020-11-27 06:57

I want to pass $data from the controller named poll to the results_view however I am getting an undefined variable error.

         


        
13条回答
  •  醉酒成梦
    2020-11-27 07:16

    In simple terms,

    $data['a'] in controller becomes $a in your view. ($data won't exist in your view, only the index will become available)

    e.g.

    Controller:    
    $data['hello']='hellow world';
    
    view:
    echo $hello;
    

提交回复
热议问题