Php 如何在codeigniter中创建文件内部视图文件夹

Php 如何在codeigniter中创建文件内部视图文件夹,php,codeigniter,Php,Codeigniter,我正在尝试使用codeigniter创建php文件,我希望在视图文件夹或控制器/模型内动态创建该文件。但我收到错误消息:fopen(应用程序/视图):无法打开流:没有这样的文件或目录。看起来像是来自codeigniter的某种限制。我怎样才能完成这项任务 我的代码: $file_location = APPPATH . "views"; $myfile = fopen($file_location, "newfile.php", "w") or die("Un

我正在尝试使用
codeigniter
创建
php
文件,我希望在视图文件夹或控制器/模型内动态创建该文件。但我收到错误
消息:fopen(应用程序/视图):无法打开流:没有这样的文件或目录
。看起来像是来自
codeigniter
的某种限制。我怎样才能完成这项任务

我的代码:

        $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);
$file\u location=APPPATH。“观点”;
$myfile=fopen($file_位置,“newfile.php”,“w”)或die(“无法打开文件!”);
$txt=“\n”;
fwrite($myfile,$txt);
fclose($myfile);

不,我认为这是一个PHP问题,不是一个代码点火器。
请参见此行:
fopen($file\u位置,“newfile.php”,“w”)

从文档中:
resource fopen(string$filename,string$mode[,bool$use\u include\u path=FALSE[,resource$context]])

所以也要改变你的fopen:
fopen($file\u location.“newfile.php”,“w”)

(我将更改为。以构造文件路径)

编辑:确保您的
$file\u位置
/
结尾,或者在
newfile.php的开头添加一个