Tag: PHP

144 月

PHP error_log() vs trigger_error()

被 error log 的訊息會被記錄到指定的位置 (php error log, mail, file..等等),而不會直接在畫面上呈現出來,然後程式會繼續往下走。而 trigger_error 則是著重於 error 的觸發 + log 用途,會視 php.ini 中 log_errors 及 error_log 的設定,來將錯誤訊息記錄到指定的位置, 並視 php.ini 中 display_errors 的設定,決定是否直接呈現在畫面上
  • PHP
  • Posted by admin  Posted on 14 4 月  0 Comments
  • Read More
223 月

PHP 開發環境開啟 E_ALL 的重要性

PHP 過於自由鬆散的語法及設定,雖然是有效降低了入門的學習曲線,卻無形中讓入門者在初學養成的關鍵階段,深深埋下隨時準備失控引爆的地雷種子而不自知。PHP 開發環境開啟 E_ALL 的重要性,換成另一面反向的說法,通常是在暗示隱藏 E_NOTICE 的隱憂。
  • PHP
  • Posted by admin  Posted on 22 3 月  0 Comments
  • Read More
023 月

PHP mysql_real_escape_string() 使用注意事項

在 DBMS 為 MySQL 時,要留意 mysql_real_escape_string() 的使用時機,要先確保產生 DB 連線資源後,才能正確使用,不然可能會產生空值。
  • PHP
  • Posted by admin  Posted on 02 3 月  0 Comments
  • Read More
023 月

PHP =& new 使用注意事項

注意 PHP 5.3 之後的版本,是已經建議廢棄 =& new 但不是所有情況的 =& 都不建議了,若原來為 =& new 則改為 = new 就好,若原來為 =& xxx::aa() 則可以不用更動
  • PHP
  • Posted by admin  Posted on 02 3 月  0 Comments
  • Read More
252 月

PHP urlencode() 使用注意事項

PHP 的 urlencode() 是針對參數值 vs htmlspecialchars() or htmlentities() 是針對整個 ? 後的查詢字串
  • PHP
  • Posted by admin  Posted on 25 2 月  0 Comments
  • Read More
232 月

PHP 依資料用途進行消毒

想要開發安全的 Web 應用程式,最重要的是正確掌握資料的「用途」狀態。最重要的是,這些「用途」的資料,應明確加以區別,不要混淆使用,一定要明確配合「用途」進行轉換。
  • PHP
  • Posted by admin  Posted on 23 2 月  0 Comments
  • Read More
311 月

開發 PHP 時可能會作的環境設定

習慣是,開發完一個函式庫,就寫一個測試檔,而在測試檔一開頭,就設定這兩行,要讓共用函式庫通過這兩行的考驗才夠健壯
  • PHP
  • Posted by admin  Posted on 31 1 月  0 Comments
  • Read More
201 月

比對條件反轉注意事項

當整個比對條件相反時,中間的串接條件,也必然相反。 寫程式時要留意,不要產生錯誤的反向邏輯 關鍵在於要確實理解 && 及 || 的有效魔力
  • PHP
  • Posted by admin  Posted on 20 1 月  0 Comments
  • Read More
191 月

strpos() 使用注意事項

在使用 strpos() 時,一定要先確保第二個參數不可以為空值, 不然就可能發生 Empty delimiter 的錯誤警告。
  • PHP
  • Posted by admin  Posted on 19 1 月  0 Comments
  • Read More