Chapter 25. PEAR Coding Standards

Table of Contents
Indenting
Control Structures
Function Calls
Function Definitions
Comments
Including Code
PHP Code Tags
Header Comment Blocks
Using CVS
Example URLs
Naming Conventions

Note: The PEAR Coding Standards applies to code that is to become a part of PEAR, either distributed with PHP or available for download via PEAR's install tool.

Indenting

Use an indent of 4 spaces, with no tabs. If you use Emacs to edit PEAR code, you should set indent-tabs-mode to nil. Here is an example mode hook that will set up Emacs according to these guidelines (you will need to ensure that it is called when you are editing PHP files):

(defun php-mode-hook ()
  (setq tab-width 4
        c-basic-offset 4
        c-hanging-comment-ender-p nil
  	indent-tabs-mode
	(not
	 (and (string-match "/\\(PEAR\\|pear\\)/" (buffer-file-name))
	      (string-match "\.php$" (buffer-file-name))))))

Here are vim rules for the same thing:

  set expandtab 
  set shiftwidth=4 
  set tabstop=4