PHP ?????????? Http put ??????????, Phphttpput

Source: Internet
Author: User

PHP ?????????? Http put ??????????, Phphttpput

???? Http put ???????????????????? Http://www.bkjia.com/article/52515.htm ??

PHP ???? $ _ GET ?? $ _ POST ?????????? $ _ PUT ????????????????????????????????????? ?????????????
???????????????? :
$ _ PUT = array ();
If ('put' = $ _ SERVER ['request _ method']) {
Parse_str (file_get_contents ('php: // input'), $ _ PUT );
}

???? Php: // input ???????????? Raw data ???????????? Parse_str ??????????

?????????????????????????? Enctype = "multipart/form-data "??????????????????????????????? ??????????????????????????? Php: // input ???????????? PHP ?????????? Content-Type ?? Multipart/form-data ??????????????????????????????????? ??????? $ _ FILES ???????????????? Raw data ????????????????????

?? Apache ?????????? Httpd. conf ?????????? RequestHeader ?????????????? Header ????????
???????????????? :
<Location "/demo. php">
RequestHeader set Content-Type foobar
</Location>

???????? Content-Type ???????? Foobar ?????????? Multipart/form-data ???????????? Php: // input ?????????????????????????? $ _ FILES ????????????????????????????????????? ????????????????? Raw data ?????????????????????????? PEAR ???????????????? HTTP_Request2_MultipartBody ??

???????????????????? GET/POST ?????????????????? JS ?????? PUT ??????????????????????????????????????? ????????? CURL ??????????????????????????????????????? ?????????????????????????
???????????????? :
Curl-x put http://www.domain.com/demo.php-d "id = 1"-d "title ="

???????????? PUT ???????? Id, title ???????????? Demo. php ?????????????????? Php: // input ??


What parameters does the file_put_contents () function require? (Php)

Int file_put_contents (string filename, string data [, int flags [, resource context])
Filename: name of the file to write data
Data: The data to be written. The type can be string, array (but not multi-dimensional array), or stream resource.
Flags: (optional) specifies how to open/write files. Possible values:
FILE_USE_INCLUDE_PATH: Check the built-in path of the filename copy.
FILE_APPEND: writes data to the end of a file in append mode.
LOCK_EX: Lock the file
Context: Optional. Context is a set of options. You can use it to modify text attributes.

File_put_contents ("test.txt", "This is another something.", FILE_APPEND );

How to enable output_buffering in PHP?

In PHP. INI, you can set the following parameters related to the output buffer:
Default name Range correction record
Output_buffering "0" PHP_INI_PERDIR
Output_handler NULL PHP_INI_PERDIR available from PHP 4.0.4
Implicit_flush "0" PHP_INI_ALL is PHP_INI_PERDIR in PHP <= 4.2.3

A simple explanation is as follows:
Output_buffering boolean/integer
When this option is set to On, output control is used in all scripts. To limit the maximum value of the output buffer, set this option to the specified maximum number of bytes (for example, output_buffering = 4096 ). Starting with PHP 4.3.5, this option is always Off in the PHP-CLI.

Output_handler string
This option redirects all the output of the script to a function. For example, when output_handler is set to mb_output_handler (), the character encoding is changed to the specified encoding. Any processing function set will automatically process the output buffer.

Note: you cannot use both mb_output_handler () and ob_iconv_handler (), or ob_gzhandler () and zlib. output_compression.

Note: Only built-in functions can use this command. For user-defined functions, use ob_start ().

Implicit_flush boolean
The default value is FALSE. If this option is changed to TRUE, PHP will make the output layer automatically Refresh after each segment of information block is output. This is equivalent to calling the flush () function in PHP after each use of functions such as print () and echo () or each HTML block.

When PHP is not used in the web environment, enabling this option has a serious impact on the performance of program execution. It is generally only recommended for debugging. In the invocation mode of cli sapi, the flag is set to TRUE by default.

See ob_implicit_flush ().

It will certainly be useful unless you modify the PHP. the INI location is not used by the system, for example, C: \ WINDOWS \ PHP. INI, of course, can be set elsewhere. In addition, the console program is not buffered.

In addition, you can Control the Output buffer in the program. For details, refer to the "CXIV. Output Control function" chapter in the manual. The main functions are as follows:

Flush -- refresh the output buffer
Ob_clean -- Clean (erase) the output buffer
Ob_end_clean -- Clean (erase) the output buffer and turn off output buffering
Ob_end_flush -- Flush (send) the output buffer and turn off output buffering
Ob_flush -- Flush (send) the output buffer
Ob_get_clean -- Get current buffer contents and delete current output buffer
Ob_get_contents -- Return the contents of the output buffer
Ob_get_flu ...... remaining full text>

Related Article

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.