Examples of $_post in PHP

Source: Internet
Author: User
Tags http post soap php server

$_post: An array of variables passed by the HTTP POST method. is an automatic global variable.

$GLOBALS [' Http_raw_post_data ']: Always produce a variable containing the original POST data. This variable is only generated when it encounters data that does not recognize the MIME type. $HTTP _raw_post_data is not available for enctype= ' multipart/form-data ' form data.

That is to say, basically $globals[' http_raw_post_data ' is the same as $_post.

But if the POST data is not recognized by PHP, you can use $GLOBALS [' Http_raw_post_data '] to receive it, such as text/xml or soap, and so on.

  • Supplemental Note: The data type recognized by PHP by default is the application/x-www.form-urlencoded standard data type.

  • It's written in the handbook.

    Always produce a variable containing the original post data. Otherwise, this variable is only generated when it encounters data that does not recognize the MIME type. However, a better way to access the raw POST data is php://input. $HTTP _raw_post_data is not available for enctype= ' multipart/form-data ' form data.

    Question: $HTTP _raw_post_data = = $_post?

    According to the manual, the answer should be no.
    If not, what is the difference between them?

  • I know the answer, as follows:

    The raw/uninterpreted HTTP postinformation can be accessed with:
    $GLOBALS [' Http_raw_post_data ']
    This was useful in cases where thepost content-type was not something PHP understands (such astext/xml).

    In other words, basically $globals[' http_raw_post_data ' and $_post are the same. However, if the POST data is not recognized by PHP, you can use $globals[' http_raw_post_data ' to receive it, such as text/xml or soap, and so on.

    PHP Default recognized data type is the application/x-www.form-urlencoded standard data type

    With the Content-type=text/xml type, submit an XML document content to the PHP server, how to get this post data.

    The raw/uninterpreted HTTP postinformation can be accessed with: $GLOBALS [' http_raw_post_data ']this are useful in cases w Here the post Content-type is Notsomething PHP understands (such as Text/xml).

    Since PHP only recognizes the application/x-www.form-urlencoded standard data type by default, the contents of the type such as text/xml cannot be parsed into the $_post array, so the prototype is retained and given to $globals[' Http_raw_ Post_data '] to receive.

    There is also a php://input that can be implemented with this function

    Php://input allows the raw data to be read from the POST. Compared to $http_raw_post_data, it brings less pressure to memory and does not require any special php.ini settings. Php://input cannot be used for enctype= "Multipart/form-data".

    application

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.