Bar*_*ris 0 codeigniter file function
在我检查了这里的问题之后,我看到我需要write_file来将文本写入.txt文件.我还在谷歌上寻找了一个关于它的教程或示例,但找不到一个简单的.
你能解释一下我如何在Codeigniter中写一些.txt文件吗?
例如,用户在注册表单上提交文本,然后用户编写的文本将显示在users.txt中.
从文档:
$this->load->helper('file');
$data = 'Some file data';
if ( ! write_file('./path/to/file.php', $data))
{
echo 'Unable to write the file';
}
else
{
echo 'File written!';
}
Run Code Online (Sandbox Code Playgroud)
在 codeIgniter 中调用file_helper.php了一个文件助手system/helpers,可以帮助您做到这一点:
$this->load->helper('file');
$data = 'My Text here';
if ( !write_file('./path/to/file.txt', $data)){
echo 'Unable to write the file';
}
Run Code Online (Sandbox Code Playgroud)
完整的文档大约file_helper是在这里。
| 归档时间: |
|
| 查看次数: |
20880 次 |
| 最近记录: |