简单直接方便快捷
如果你想用原生的方法导出的话 更方便了
直接sql查询数据
然后拼接字符串
新建/打开文本
写入字符串~
我想这个东西初学者都会我就不多写代码了
①.、html表单
步骤就是这样了
//记录返回值
? ? ? $write_data_a = [
? ? ? ? ? 'html_url'? =? $getUrl,
? ? ? ? ? 'ip'? ? = $this-get_real_ip(),
? ? ? ? ? 'time'? =? date("Y-m-d H:i:s",time()),
? ? ? ? ? 'res'? = $response
? ? ? ];
//转化为JSON
? ? ? $write_data_a = json_encode($write_data_a) . '||' . "\n";
? ? ? $date = date("Y-m-d", time());
//项目路径目录,判断是否存在,不存在则创建
? ? ? if(!is_dir($lujing)){
? ? ? }
//文件,判断是否存在,不存在则创建
? ? ? //以读写方式打写指定文件,如果文件不存则创建
? ? ? if(file_exists($TxtFileName))
? ? ? {
//存在,追加写入内容
? ? ? ? ? file_put_contents($TxtFileName, $write_data_a, FILE_APPEND);
? ? ? else
//不存在,创建并写入
? ? ? ? ? if( ($TxtRes=fopen ($TxtFileName,"w+")) === FALSE){
? ? ? ? ? ? ? exit();
? ? ? ? ? }
? ? ? ? ? if(!fwrite ($TxtRes,$write_data_a)){ //将信息写入文件
? ? ? ? ? ? ? fclose($TxtRes);
? ? ? ? ? fclose ($TxtRes); //关闭指针
以上就是土嘎嘎小编为大家整理的php写数据到txt的简单介绍php写数据到txt的简单介绍相关咨询咨询主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!