Example explanation of $_POST in php

零下一度
Release: 2023-03-13 21:12:01
Original
2669 people have browsed it

$_POST: Array of variables passed via the HTTP POST method. is an automatic global variable.

$GLOBALS['HTTP_RAW_POST_DATA']: Always generate variables containing raw POST data. This variable is only generated when data of an unrecognized MIME type is encountered. $HTTP_RAW_POST_DATA For enctype="multipart/form-data" form data is not available.

That is to say, basically $GLOBALS['HTTP_RAW_POST_DATA'] and $_POST are the same.

But if the posted data is not recognized by PHP, you can use $GLOBALS['HTTP_RAW_POST_DATA'] to receive it, such as text/xml or soap, etc.

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

  • This is what the manual says

    Always generate variables containing the original POST data. Otherwise, this variable is only generated when data of an unrecognized MIME type is encountered. However, a better way to access the raw POST data is php://input. $HTTP_RAW_POST_DATA for enctype="multipart/form-data" Form data is not available.

    Problem: $HTTP_RAW_POST_DATA == $_POST ?

    According to the manual, the answer should be no.
    If they are different, what is their difference?

  • ##I know the answer, as follows:

    The RAW/uninterpreted HTTP POST information can be accessed with:
    $GLOBALS['HTTP_RAW_POST_DATA']
    This is useful in cases where the post Content-Type is not something PHP understands (such as text/xml).

    That is, basically $GLOBALS['HTTP_RAW_POST_DATA'] and $_POST is the same. But if the data posted is not recognized by PHP, you can use $GLOBALS['HTTP_RAW_POST_DATA'] to receive, such as text/xml or soap etc.

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

    Use Content-Type=text/xml Type, submit an xml document content to the php server, how to obtain this POST data.

    The RAW / uninterpreted HTTP POST information can be accessed with: $GLOBALS['HTTP_RAW_POST_DATA'] This is useful in cases where the post Content-Type is not something PHP understands (such as text/xml).

    Since PHP only recognizes application/x-www.form-urlencoded standard data types by default, it cannot handle content such as text/xml. It is parsed into a $_POST array, so the prototype is retained and passed to $GLOBALS['HTTP_RAW_POST_DATA'] to receive.

    There is another item php://input This function can also be implemented

    php://input allows reading the raw data of POST. and It puts less pressure on memory than $HTTP_RAW_POST_DATA and doesn't require any special php.ini set up. php://input cannot be used with enctype="multipart/form-data".

    application

The above is the detailed content of Example explanation of $_POST in php. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!