記錄一些 PHP 挺重要但又不常用的東西
1. php://input ─ 抓post丟的全部資料
說明: php://input allows you to read raw POST data. It is a less memory intensive alternative to $HTTP_RAW_POST_DATA and does not need any special php.ini directives. php://input is not available with enctype="multipart/form-data".
用法: $HTTP_RAW_POST_DATA = file_get_contents( 'php://input' );
2. fputcsv ─ 產生 CSV 檔
fgetcsv ─ 讀取 CSV 檔
http://us2.php.net/manual/en/function.fputcsv.php
http://us2.php.net/manual/en/function.fgetcsv.php
另外在產生 \r\n 時, 要記得用雙引號.
因為單引號:表純字串
雙引號:會去判斷與解釋字串裡的變數
3. php 在檔案內 直接 寫進 error log 方法
ini_set("error_log", "on");
error_log(print_r($location_key, true));
4. 處理UTF8編碼
記得先安裝php-mbstring
請先 登入 以發表留言。