问题
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