I am trying to create php file using codeigniter, I want to create that file inside views folder or inside controller/ model dynamically. But I am getting error Message: fopen(application/views): failed to open stream: No such file or directory. Looks like kind of restriction from codeigniter. How can I achieve this task ?
My Code:
$file_location = APPPATH . "views";
$myfile = fopen($file_location, "newfile.php", "w") or die("Unable to open file!");
$txt = "<?php\n ";
$txt .= "echo 'something';\n" ;
$txt .= "?>\n ";
fwrite($myfile, $txt);
fclose($myfile);