How write a new file in codeigniter?

安稳与你 提交于 2019-12-23 19:40:04

问题


First I want to load a view file into a variable, then I need to create a new file by writing the data to new file.ie,Like creating a copy of a view file.

$vPath = "home/muhammed/desktop/newfolder";
$ViewData=$this->load->view('test/show',TRUE);
mkdir($vPath);
write_file("$vPath/test.php", $ViewData);

But the code given is not working.


回答1:


change:

$ViewData=$this->load->view('test/show',TRUE);

to

$ViewData=$this->load->view('test/show', "", TRUE);

as second parameter of load->view is data and last param TRUE makes it string to be loaded to the variable See: codeIgniter Views



来源:https://stackoverflow.com/questions/14956300/how-write-a-new-file-in-codeigniter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!