一個關於 GLOBALS 使用的怪現象

在整理一套運作在 php 4.x 的舊程式準備移植到新的 PHP 5.x 時, 順便動手改寫所有的 cookie function 成為一個獨立的 class, 卻無意中發現一個關於 GLOBALS 使用上的怪現象. Read the rest of this entry »

Posted in PHP. No Comments »

PDOStatement->execute 簡記

語法

bool PDOStatement::execute ([ array $input_parameters= array() ] )

說明

PDOStatement->execute 負責執行 PDO::prepare 的 SQL 描述, 返回布林值。

Read the rest of this entry »

Posted in PHP. No Comments »

關於圖形驗證碼產生器

圖形驗證碼的使用已行之有年。但,也破之有年。好久以前自己剛完成一個圖形驗證碼程式時,曾簡略地研究的一下 “留言機器人” 這個課題,那時就發現有網站發表如何攻破那時廣泛使用中的圖形驗證碼產生器。個人實在是沒有生命投入這種無意義的留言機器人攻防戰中。

Read the rest of this entry »

Posted in PHP. No Comments »

PDOStatement->bindParam 簡記

語法

bool PDOStatement::bindParam ( mixed $parameter , mixed &$variable [, int $data_type [, int $length [, mixed $driver_options ]]] )

說明

綁定 PHP 變數到對應的 “名稱描述” 或 “問號描述”, 可加上簡易的資料格式與長度驗證. 以 Boolen 為返回值.

Read the rest of this entry »

Posted in PHP. No Comments »

PDO::prepare 簡記

PDO::prepare

這是方法提供 SQL 描述作前沿驗證,屬於較為嚴謹的使用方法。由於 PDO::prepare 僅作 SQL 描述的驗證,真正的執行需搭配 PDOStatement::execute() 方法使用。

PDOStatement PDO::prepare ( string $statement [, array $driver_options= array() ] )

Read the rest of this entry »

Posted in PHP. No Comments »

PDO::query 簡記

PDO::query

可通泛應用的方法。負責執行交付的 SQL 陳述,並將回傳的執行結果作為 PDOStatement 物件。此方法相當適合一般性的 SELECT 語意使用。

Read the rest of this entry »

Posted in PHP. No Comments »

PDO::exec 簡記

PDO::exec

在 PDO 當中最為直接簡要的方式莫過於 PDO::exec。

int PDO::exec ( string $statement )

Read the rest of this entry »

Posted in PHP. No Comments »

strip_tags 函數 簡記

strip_tags() 除去 string 中的 html tags 是個簡便的方案。語法如下:

string strip_tags ( string $str [, string $allowable_tags ] )

不過假使 string source 的 html tags 不完整或有語法錯誤,將會濾除的正確性。由於有此缺陷在應用上必須謹慎。

Read the rest of this entry »

Posted in PHP. No Comments »

JSDoc 與 phpDocumentor

過去使用 PSPad 編寫 php 或 javascrip 時僅會在 code 中留下極為有限的注解, 甚至在有機會重新整理時, 會移除所有的注解. 近日改用 Eclipse 撰寫後, 對 IDE 環境自動顯示註解的功能漸生好感, 這不知道是否是逐漸墮落的開始? 儘管自己並不太依賴 IDE 提供的舒適, 但難保有一天不會真的變懶了.

不管如何, 當嘗試開始刻意地在 code 中寫下註解時才發現, 自己得同時面對 JSDocphpDocumentor 這兩種規範. 窩…. 沒事找事. 得到工具的幫助, 卻也得依循工具的規範, 還當真沒有白吃的午餐…. 不過一次看兩個規範, 時間上也划算. 事實上兩者有相當大的部分是共通的. 這點對一般性的注解或說明來說, 已經足夠了.

以下的紀錄將會陸續與持續性的增修自己閱讀後的雜記 :

Read the rest of this entry »

wordpress 2.7.1 ~ 2.8.1 vs PHP 5.3.0 問題

剛剛將 DNS 轉到新主機後發現原本跑的好好的 Wordpress 2.7.1 碰上 PHP 5.3.0 出現了一些錯誤訊息。上 wordpress 官網看到一則關於 wordpress 2.8.0 與 PHP 5.3.0 的問題回應,症狀似乎相同,就動手將更新到最新的 2.8.1 版。結果一樣! @#$…

Read the rest of this entry »