在codeigniter上获取文本文件的内容

时间:2015-03-19 11:49:47

标签: php codeigniter

我打算获取txt文件的内容,我正在使用Codeigniter框架。我把url.txt的内容放在根文件夹中。

$link_univ = 'http://localhost/perpus3/index.php/webService/wsdl';
$link_mipa = 'http://localhost/perpus_mipa/index.php/webService/wsdl';

在文件夹控制器中,我有Koleksi.php,我创建了一个函数来获取url.txt的内容

$lines = file('url.txt');
foreach ($lines as $line_num => $line){
    print $line. "<br />\n"; 
}

1 个答案:

答案 0 :(得分:1)

你应该看看the file helper。它会为你做所有这些。例如:

$this->load->helper('file');
$string = read_file('./path/to/file.php');

现在$ string变量应该有来自file.php的文本。