如何在Codeigniter中将数据写入.txt文件 [英] How to write data into .txt file in codeigniter

查看:98
本文介绍了如何在Codeigniter中将数据写入.txt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在资产名称中有一个文件夹为login。我的疑问是如何设置路径。

I have a folder in assets name is login.My doubt is what how to set the path.

$data=$id.'~'.$expense_type.'~'.$amount.'~'.$exp_date.'<br>';

$todate= date('Y-m-d');
echo $todate;
if ( ! write_file('.../assets/login/log_'.$todate.'.txt', $data))
{
echo 'Unable to write the file';
}
else
{ 
echo 'File written!';
}

关于数据没有问题,但是我设置的路径错误

No problem about the data but the path is wrong i set


我的路径是'localhost / project / pro / application / assets / login /((特定的
.txt文件)'

my path is 'localhost/project/pro/application/assets/login/(specific .txt file)'

输出无法写入文件

推荐答案

使用 APPPATH 。这是您的应用程序文件夹的路径

Use APPPATH. It is the path up to your application folder

if ( ! write_file(APPPATH."assets/login/log_$todate.txt", $data))

这篇关于如何在Codeigniter中将数据写入.txt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆