Category Archives: PHP

You are *required* to use the date.timezone setting or the date_default_timezone_set() function

  近日在轉移Mantis時所發生的問題,剛好在google上搜尋一下得知道答案, 問題的產生點是在於php 5後的版本,所以只需要再增加timezone的設定就 可以正常了。 Mantis: php.ini date.timezone = "Asia/Taipei" config_inc.php date_default_timezone_set(‘Asia/Taipei’); date_default_timezone_set(‘UTC+8′);   WordPress: wp-config.php date_default_timezone_set(‘Asia/Taipei’); wp-includes/functions.php     *在第一個 function 前面加上 date_default_timezone_set(‘UTC+8′); date_default_timezone_set(‘Asia/Taipei’); php.ini date.timezone = "Asia/Taipei" 至於其他的timezone可以到php.net查詢

Posted in PHP, Wordpress | Tagged , | 迴響已關閉

PHP程式產生送傳檔案功能(下載檔案)

有時候為了利用權限管制下載必需使用程式的技巧 讓Browser知道目前程式是要傳送檔案給Browser, 而Browser就會跳出視窗提示使用者目前是要將檔案 另存或直開啟,像下圖的畫面, 在PHP的程式中要如何用最簡潔的方式產生這種行為?目前所測試的方法如下: [code language='php'] [/code] 將檔案存成php檔案後執行會看到像下圖中的畫面 Firefox: IE: <?php $dl_file = ‘TEST.D’; header("Content-Disposition: attachment; filename=" . urlencode($dl_file)); header("Content-Transfer-Encoding: binary"); header("Content-Type: application/download"); header("Content-Length: " . filesize($dl_file)); readfile($dl_file); ?> 注意紅色這段,如果將這段 header("Content-Type: application/download"); 刪除時則Browser出現的提示為 Firefox IE: 很多方式利用PHP所提供的HEADER function通知Browser做某些事,整個規範 在HTTP/1.1 specification中有提到很多,最常用header來做轉址的動作, … Continue reading

Posted in PHP, 工作日誌 | Tagged | 578 Comments