部落格文章訂閱


貧窮不能等,因為時間久了,你就會貧窮習慣了;
夢想不能等,因為努力晚了,人老就無能為力了;
學習不能等,因為懂得少了,就沒本事夢想成真了;
健康不能等,因為身體垮了,人生的一切就都沒了。


自訂搜尋

找不到想要的文章嗎? 請直接再下面的搜尋框裡輸入要查詢文章內容關鍵字 ,就能夠更快速的取得想要閱讀的問題喔~~謝謝大家的支持與愛護~若有任何建議事項, 歡迎透過留言板留言給我喔!!


  • 你不能決定生命的長度,但可以控制它的寬度;
  • 你不能左右天氣,但可以改變心情;
  • 你不能改變容顏,但可以展現笑容;
  • 你不能控制他人,但可以掌握自己;
  • 你不能預知明天,但可以利用今天;
  • 你不能樣樣勝利,但可以事事盡力。

free counters

目前分類:PHP程式設計 (51)

瀏覽方式: 標題列表 簡短摘要

由於我有安裝 WordPress Database Backup 和 Spam Karma 2 這兩個 Plugins ,加上我的 Blog 標題是 Non-ASCII 的文字(我是用 UTF-8 編碼),所以常發生收信收到亂碼的窘境!

經過 Google 大神一番查詢和整理,終於找出了解決的方法。 XD

因為 RFC 822 規定標頭訊息(message headers)得用 ASCII 來編碼,所以當你使用 Non-ASCII 的文字做為你的內容時(像是 “螺絲起子” 是中文,用 UTF-8 編碼),就會發生亂碼的狀況。

畢竟 RFC 822 是早期訂定的東西,沒有考慮這麼的多,所以後續就產生了 RFC 2047 來解決這個惱人的問題。

在這邊也不打算要講道,我就跳過一些比較細節的部份,直接來講解決的方法(其實是怕多講多錯 XD)。

Frank 發表在 痞客邦 留言(0) 人氣()

mysql查询默认是不区分大小写的 如:


select * from table_name where a like 'a%'
select * from table_name where a like 'A%'
效果是一样的。

Frank 發表在 痞客邦 留言(0) 人氣()

PHP本身可以用 rmdir 刪除目錄 ,但是必須限制於空目錄 ,因此 ,若要刪除含有檔案的目錄 ,則必須使用 unlink 逐一刪除檔案
再使用 rmdir 刪除目錄 ,請參考以下的範例程式 ,可以另存成 .php 檔案 ,再 require 它,然後  call removeDir() function 即可.

  1. function removeDir($dirName)
  2. {
  3.     $result = false;
  4.     if(! is_dir($dirName))
  5.     {
  6.         trigger_error("目錄名稱錯誤", E_USER_ERROR);
  7.     }
  8.     $handle = opendir($dirName);
  9.     while(($file = readdir($handle)) !== false)
  10.     {
  11.         if($file != '.' && $file != '..')
  12.         {
  13.             $dir = $dirName . DIRECTORY_SEPARATOR . $file;
  14.             is_dir($dir) ? removeDir($dir) : unlink($dir);
  15.         }
  16.     }
  17.     closedir($handle);
  18.     $result = rmdir($dirName) ? true : false;
  19.     return $result;
  20. }

Frank 發表在 痞客邦 留言(0) 人氣()

We've all seen it happen.

You put up a registration page on your site, hoping that visitors will leave you their email addresses so that you can stay in touch with them when you've got a new product for sale. Or a new tutorial that they might be interested in. Or you want to send them some "information from carefully screened third parties with whom we maintain a strategic relationship." Or maybe you want something in return before you give them that valuable whitepaper that you spent two months completing.

Whatever the reason, you happily construct your registration page, set up a database table to track the incoming email addresses, and publish it live. And sure enough, the registrations start coming in.

To mickey@mouse.com. And donald@duck.com. And emailthis@hahaha.com. You get the idea -- users are registering with bogus email addresses at domains that don't even exist. Not only are you going to be sending mail to nonexistent addresses, but they clutter up your database and cause maintenance headaches because they need to be cleaned out.

Make Sure They're at Least Real

One way to help address this problem is to make sure that a user's email address actually corresponds to a real email domain. Using PHP, you can check the domain registration records to see if the domain a user submitted to your site is real. To do this, we'll use PHP's checkdnsrr function.

Frank 發表在 痞客邦 留言(0) 人氣()

用PHP編寫一種幫助處理系統。必須知道處理完最後一位客戶的問題後已經過去了多長時間?過去用ASP時解決這個問題相當簡單,ASP有相應的函數 DateDiff可以給出兩個日期間間隔多少月、多少天和多少秒。當我搜尋完PHP手冊後我發現PHP並沒有類似的函數

本文包含以下內容:
1、 得到目前的日期和時間-我們有多少種方式?
2、 改變日期顯示的方式-日期和時間的顯示形式

Frank 發表在 痞客邦 留言(1) 人氣()

以MySQL為例 ,在建立新的資料表時 ,會為指定的資料夾記錄欄位指定編碼方式 ,以當前為了製作多語系的網站內容 ,通常會指定為 UTF8 的部分 ,很多書都在寫 ,指定資料表時 ,只要指定 utf8_unicode_ci 即可, 但是在下拉編碼清單裡面 可以看見除了  utf8_unicode_ci  之外的UTF8選項還有 utf8_bin 可以選擇 ,那麼 究竟 utf8_bin 和  utf8_unicode_ci 差別在哪裡呢?

SearchResult1 

SearchResult2 

其實 ,   utf8_unicode_ci 後面的 _ci 代表著 case insensitive 的意思 ,也就是說 當使用Like 進行資料比對時 ,不會區分大小寫.

Frank 發表在 痞客邦 留言(0) 人氣()

<?php
$str = " This line contains\tliberal \r\n use of whitespace.\n\n";

// 移除前後空白字
$str = trim($str);

Frank 發表在 痞客邦 留言(0) 人氣()


PHP 內附的 mail() 雖然用起來很方便了,但是還是有某些功能上的限制,例如:夾帶檔案、寄送 HTML 時內嵌圖檔等等,這時就需要借助 PEAR Mail了。

PEAR Mail 有兩個基本的 classes 可以使用:


Frank 發表在 痞客邦 留言(0) 人氣()

要將陣列的資料讀出 ,在PHP程式語言裡 ,我們都知道可以使用 foreach ,當存取的陣列是 一維陣列 時, 並沒有什麼問題
若存取的陣列是為二維陣列或三維陣列時 ,若直接使用 foreach 則將會得到 array 的字串 ,並沒有辦法真的得到陣列的資料值

那麼該怎麼處理呢?

 

Frank 發表在 痞客邦 留言(0) 人氣()

以下程式碼會介紹如何擷取遠端網頁資訊

包括 HTML tag 裡面的 Title, Description 及 Keywords:

  1. <?php

Frank 發表在 痞客邦 留言(0) 人氣()

開發網站應用程式的過程,或許會需要提供使用者上傳檔案的功能,這個時候就可以透過HTML表單的 文字方塊 輔助達成 ,並且 ,請記得將 INPUT 的 TYPE 改成 FILE ,才會出現瀏覽的功能鈕 ,讓使用者選擇檔案 ,並且 ,請記得設定 enctype 的屬性為 multipart/form-data 如此才能順利接收檔案, 並且交由後端程式進行處理 ,請參考以下的範例 ,謝謝.

HTML表單的範例.

<form enctype="multipart/form-data" action="__URL__" method="POST">
    <!-- MAX_FILE_SIZE must precede the file input field -->
    <input type="hidden" name="MAX_FILE_SIZE" value="30000" />

Frank 發表在 痞客邦 留言(0) 人氣()

«123