程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 網頁編程 >> PHP編程 >> 關於PHP編程 >> PHP??????????HTTP PUT??????????,phphttpput

PHP??????????HTTP PUT??????????,phphttpput

編輯:關於PHP編程

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=a"

????????????PUT????????id, title????????????demo.php??????????????????php://input??


file_put_contents()函數需要什參數?(php)

int file_put_contents ( string filename, string data [, int flags [, resource context]] )
filename:要寫入數據的文件名
data:要寫入的數據。類型可以是 string,array(但不能為多維數組),或者是 stream 資源
flags:可選,規定如何打開/寫入文件。可能的值:
FILE_USE_INCLUDE_PATH:檢查 filename 副本的內置路徑
FILE_APPEND:在文件末尾以追加的方式寫入數據
LOCK_EX:對文件上鎖
context:可選,Context是一組選項,可以通過它修改文本屬性

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

PHP裡的output_buffering 怎開啟?

在PHP.INI可以設置以下與輸出緩沖有關的:
名稱 默認值 作用范圍 修正記錄
output_buffering "0" PHP_INI_PERDIR
output_handler NULL PHP_INI_PERDIR 自 PHP 4.0.4 起可用
implicit_flush "0" PHP_INI_ALL 在 PHP <= 4.2.3 版本中是 PHP_INI_PERDIR

簡單解釋如下:
output_buffering boolean/integer
該選項設置為 On 時,將在所有的腳本中使用輸出控制。如果要限制輸出緩沖區的最大值,可將該選項設定為指定的最大字節數(例如 output_buffering=4096)。從PHP 4.3.5 版開始,該選項在 PHP-CLI 下總是為 Off。

output_handler string
該選項可將腳本所有的輸出,重定向到一個函數。例如,將 output_handler 設置為 mb_output_handler() 時,字符的編碼將被修改為指定的編碼。設置的任何處理函數,將自動的處理輸出緩沖。

注意: 不能同時使用 mb_output_handler() 和 ob_iconv_handler(),也不能同時使用 ob_gzhandler() 和 zlib.output_compression。

注意: 只有內置函數可以使用此指令。對於用戶定義的函數,使用 ob_start()。

implicit_flush boolean
默認為 FALSE。如將該選項改為 TRUE,PHP 將使輸出層,在每段信息塊輸出後,自動刷新。這等同於在每次使用 print()、echo() 等函數或每個 HTML 塊之後,調用 PHP 中的 flush() 函數。

不在web環境中使用 PHP 時,打開這個選項對程序執行的性能有嚴重的影響,通常只推薦在調試時使用。在 CLI SAPI 的執行模式下,該標記默認為 TRUE。

參見 ob_implicit_flush()。

設置了肯定會有用的,除非你修改的PHP.INI位置不是系統使用的那個,比如一般是C::\WINDOWS\PHP.INI,當然可以設置到其它地方。另外控制台程序是不緩沖的。

另外,你還可以在程序裡面控制輸出緩沖,請參考手冊裡面的“CXIV. Output Control 輸出控制函數”那一章,主要有如下函數:

flush -- 刷新輸出緩沖
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......余下全文>>
 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved