在CodeIgniter中的视图文件中写入数据

I am trying to write some JSON data in a view file in CodeIgniter.

But it shows an error:

Message: fopen() [function.fopen]: Filename cannot be empty

The controller function is as follows:

public function write_in_a_view_file() {

    $data = array();
    $data['title'] = "Write This Title In a View File";

    $view_file = $this->load->view('result.php');

    $fp = fopen($view_file, 'w');
    fwrite($fp, json_encode($data));
    fclose($fp);

}
查看全部
dtm41506
dtm41506
2014/10/22 11:17
  • codeigniter
  • json
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复