加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

使用PHP写入数据到文件

发布时间:2020-12-13 13:15:35 所属栏目:PHP教程 来源:网络整理
导读:我需要使用下面的代码发布数据到php文件,将其保存在文本文件中. 我只是不知道如何创建php文件接收下面的数据并将其保存在文本文件中. 尽可能简单. 任何人都可以帮助,id非常感谢. try { // Add your data ListNameValuePair nameValuePairs = new ArrayListNa
我需要使用下面的代码发布数据到php文件,将其保存在文本文件中.
我只是不知道如何创建php文件接收下面的数据并将其保存在文本文件中.
尽可能简单.

任何人都可以帮助,id非常感谢.

try {  
    // Add your data  
    List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);  
    nameValuePairs.add(new BasicNameValuePair("stringData","12345"));  
    nameValuePairs.add(new BasicNameValuePair("stringData","AndDev is Cool!"));  
    httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));  

    // Execute HTTP Post Request  
    HttpResponse response = httpclient.execute(httppost);  
    String responseText = EntityUtils.toString(response.getEntity()); 
    tv.setText(responseText);             
} catch (ClientProtocolException e) {  
    // TODO Auto-generated catch block  
} catch (IOException e) {  
    // TODO Auto-generated catch block  
}
简单如下:
file_put_contents('test.txt',file_get_contents('php://input'));

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读