以下のコードで、phpに文字列を送ろうとしましたが、うまくいきません。
エラーはなにも出ていません。
java
1String HTML = "html文"; 2HttpURLConnection connection = null; 3try{ 4 5 URL url = new URL("http://xxxxxx.xxx/centerText.php?txt=" + URLEncoder.encode(HTML, "UTF-8")); 6 connection = (HttpURLConnection)url.openConnection(); 7 connection.connect(); 8} catch(IOException ex){ 9 10 ex.printStackTrace(); 11} finally{ 12 13 connection.disconnect(); 14}
サーバーにあるcenterText.phpファイル
php
1<?php 2 $text = $_GET["txt"]; 3 $content = file_put_contents("center.txt", $text); 4?>
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。