How write a new file in codeigniter?

codeigniter, file-io, loadview, php

Solution

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

Problem

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.

Original source