目錄表

php 程式碼撰寫標準規則

- 變數命名規則

- 常數命名規則

- 函式(Functions)命名規則

- Classes 命名規則

- 檔案命名規則

- SQL 格式

      $query = "SELECT *
      	FROM $g_mantis_bug_table
      	WHERE id='1'";

- 一般通用格式

:
<TAB>if ( is_array( gpc_get( 'show_category', null ) ) ) {
<TAB><TAB>$f_show_category = gpc_get_string_array( 'show_category', META_FILTER_ANY );
<TAB>} else {
<TAB><TAB>$f_show_category = gpc_get_string( 'show_category', META_FILTER_ANY );
<TAB><TAB>$f_show_category = array( $f_show_category );
<TAB>}
:
:
<?php require_once( 'core.php' ) ?>
<?php auth_ensure_user_authenticated() ?>
<?php
        $f_type = gpc_get_int( 'type', -1 );
:
?>

- 其他

- 頁面標準

<?php
# 專案代號 - 專案名稱
# Copyright (C) 2002 - 2005  專案負責人 - 聯絡 E-Mail
# This program is distributed under the terms and conditions of the GPL <- 採用的版權方式
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: 檔案名稱,v 版本編號 異動日期 時間 異動者 Exp $
# --------------------------------------------------------
?>
 
例如 :
 
<?php
# viaDocExg - 公文電子交換系統
# Copyright (C) 2006 - 2007  Jonathan Tsai - [email protected]
# This program is distributed under the terms and conditions of the GPL
# See the README and LICENSE files for details

# --------------------------------------------------------
# $Id: main.php,v 1.00 2007/1/02 上午 12:07 jonathan Exp $
# --------------------------------------------------------
?>

- 大括號和小括號

      for (...) {
          blah
      }
 
      或
 
      if (...) {
          blah
      }
      if (...) {
          blah1
      } else {
          blah2
      }

- 邏輯運算與判別式

- 字串

- 註解

:
    $t_setting_arr['relationship_bug'] = 0;
    $t_custom_fields = custom_field_get_ids(); # @@@ (thraxisp) This should really be the linked ids, but we don't know the project
    $t_custom_fields_data = array();
:

- 程式碼編輯工具應該有的特點

1)
原則應該採用 Smarty 的方式顯示 HTML
2)
EOF Construct 如果有比較好的翻譯或解釋請在告訴我..
3)
原則上如果是 HTML, 應該是呼叫 smarty 的 display()
4)
Notepad++ 是 OpenSource 免費好用編輯軟體, 作者是侯今吾先生
5)
EditPlus 2.11 我覺得就夠用了, 千萬不要使用中文化等非原始公司提供的版本, 否則存成 UTF-8 可能會和 UltraEdit 一樣出現怪異的問題