Codeigniter: Passing data from controller to view

后端 未结 13 2156
忘了有多久
忘了有多久 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

    The view wouldn't call the data 'data'

    The controller would include an associative index (not sure if that's correct nomenclature) for data e.g 'stuff' looking thus $data['stuff']

    You'd echo in the view so: echo $stuff; not echo $data;

    I am a v lowly code fiddler but do really like CodeIgniter so excuse me if i've got this arse about tit.

    One more thing - surely your constructor function is a bit of a waste. All that loading of libraries and helpers is done with the autoload file.

提交回复
热议问题