How do I write a new file in codeigniter?
First I want to load the view file into a variable, then I need to create a new file by writing the data to new file.ie, Like making a copy of the view file.
$vPath = "home/muhammed/desktop/newfolder";
$ViewData=$this->load->view('test/show',TRUE);
mkdir($vPath);
write_file("$vPath/test.php", $ViewData);
But this code doesn't work.
+3
source to share
1 answer
changes:
$ViewData=$this->load->view('test/show',TRUE);
to
$ViewData=$this->load->view('test/show', "", TRUE);
since the second parameter load->view
is data and the last parameter is TRUE causes it to load the string into a variable See: codeIgniter Views
+4
source to share