title: Java URLConnection to php
body: <p>How to write this code in php? </p>
  
  <p>What i should use? CURL? fsockopen ? and what is actually send to server (outputString is a post / get and what its variable name)? </p>
  
  <pre><code>URL url = new URL(targetURL);
  final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
  conn.setRequestMethod("POST");
  conn.setRequestProperty("Content-Type","text/xml");
  conn.setDoOutput(true);
  
  OutputStream out = conn.getOutputStream();
  out.write(outputString.getBytes("UTF-8"));
  out.close();
  
  conn.connect();
  
  final int code = conn.getResponseCode();
  final String contentType = conn.getContentType();
  final StringBuffer responseText = new StringBuffer();
  InputStreamReader in = new InputStreamReader(conn.getInputStream(),"UTF-8");
  
  char[] msg = new char[2048];
  int len;
  while ((len = in.read(msg)) &gt; 0) {
      responseText.append(msg, 0, len);
  }
  </code></pre>
  
  <p>Thank you for any answer.</p>