Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Codeigniter生成文本视图_Codeigniter - Fatal编程技术网

Codeigniter生成文本视图

Codeigniter生成文本视图,codeigniter,Codeigniter,我需要生成数据的文本视图,但有些链接工作正常,但有些没有以文本形式显示结果 -CH CIDR不是文本格式 -AF CIDR为文本格式 我的代码如下: $cidr_result = $this->webmodel_downloads->singlecountrycidr($country_code2); //$this->load->helper('text'); //$this->load->h

我需要生成数据的文本视图,但有些链接工作正常,但有些没有以文本形式显示结果

  • -CH CIDR不是文本格式
  • -AF CIDR为文本格式
我的代码如下:

            $cidr_result    = $this->webmodel_downloads->singlecountrycidr($country_code2);
        //$this->load->helper('text');
        //$this->load->helper('file');
        //echo "# Generated ". date('Y-m-d')."\n";
        $this->output->set_content_type('text/plain', 'UTF-8');
        $this->output->set_header("Content-Type: text/plain");
        echo "# Generated ". date('Y-m-d').PHP_EOL;
        if (!empty($cidr_result)){
            foreach($cidr_result as $row){
            echo $row['value'].PHP_EOL;
            //print_r($row['value'].PHP_EOL);
            }
        }

如果我做错了,请帮助我。谢谢

我不知道这背后的技术原因,但我没有使用CodeIgniter函数作为文本标题,而是使用PHP标题,它工作得很好

header ("Content-type: text/plain");

检查CI force_download()@:
如果您将第二个参数设置为NULL,并且$filename是一个现有的可读文件路径,则将改为读取其内容。
嗨,Vickel,谢谢您的回答,但我没有下载该文件,我是从数据库获取数据并将其生成为文本视图。