[PHP] header下載檔案 搭配資料庫

剛剛在 ECstart 看到有人詢問 header檔案下載錯誤 發現網站義工有回答到這個function,所以就紀錄下來了 function dl_file($file){ //First, see if the file exists if (!is_file($file)) { die("404 File not found!"); } //Gather relevent info about file $len = filesize($file); $filename = basename($file); $file_extension = strtolower(substr(strrchr($filename,"."),1)); //This will set the Content-Type to the appropriate setting for the file switch( $file_extension ) { case "pdf": $ctype="application/pdf"; break; case "exe": $ctype="application/octet-stream"; break; case "zip": $ctype="application/zip"; break; case "doc": $ctype="application/msword"; break; case "xls": $ctype="application/vnd.ms-excel"; break; case " [Read More]
php 

[PHP] 如何切割中文標題

今天看到酷!學園討論區,php版有人問說要如何切割中文字,結果我自己以前弄的一個function就貼了上去,如下

function cut_word($text, $num){
if(strlen($text) > $num) {
   for($i=0;$i<$num;$i++) {
      $ch=substr($text,$i,1);
      if(ord($ch)>127) $i++;
      }
      $text= substr($text,0,$i).".";
   }
   return $text;
}
[Read More]
php 

FreeBSD + Lighttpd + php + mysql 安裝過程

系統環境 :FreeBSD 6.0-RELEASE 安裝過程如下: mysql-server-5.0.24a php5-5.1.6 lighttpd-1.4.11_1 先安裝 lighttpd cd /usr/ports/www/lighttpd/ make config [X] OPENSSL Enable SSL support [ ] OPENLDAP Enable LDAP support [X] MYSQL Enable MYSQL support [X] IPV6 Enable IPV6 support [X] CML Enable Cache Meta Language support make install clean 安裝 mysql cd /usr/ports/databases/mysql50-server make install clean WITH_CHARSET=utf8 WITH_LINUXTHREADS=yes 安裝 php cd /usr/ports/lang/php5 cd /usr/ports/lang/php5-extensions/ make config 選擇你想要的 extensions 灌好之後 就可以用了 然後打開 家目錄設定 userdir.path = “public_html” userdir. [Read More]