开发者

post method in php

I am trying to send data through post method in android . But how I can receive data in server. My server is in php. I found a method in php $_post[]. how can i use it? my client code is

client=new DefaultHttpClient();
            HttpPost request=new HttpPost("http://10.0.2.2/php_server/index.php");
            HttpEntity entity;

            try
            {
                StringEntity string=new StringEntity("I am android");

                 entity=string;
                 request.setEntity(entity);

                HttpResponse response=client.execute(request);
            }
            catch(Exception e)
            {
              开发者_StackOverflow社区  Log.e("socket connection", e.toString());
            }


It is very basic of PHP. $_POST is super-global array of PHP that stores data that was sent to a particular script using POST method.

You can use it as any other PHP array

Code below will output all the keys of $_POST and corresponding values:

foreach ($_POST as $key => $value) {
  echo $key . ' = ' . var_export($value, true);
}

If you know which key you need exactly, you can get it using [] on array like so:

$my_value = $_POST['my_post_field_sent_by_android_app'];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜