PHP: Rules - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

Tips Userland Naming Guide

Last updated: Sat, 27 Jan 2007

view this page in

# Rules

The following list gives an overview of which rights the PHP project reserves for itself, when choosing names for new internal identifiers. The definitive guide is the official CODING STANDARDS:

- PHP owns the top-level namespace but tries to find decent descriptive names and avoid any obvious clashes.

- Function names use underscores between words, while class names use the lower bumpy camel rule (there are some exceptions for older classes and functions).

- PHP will prefix any global symbols of an extension with the name of the extension. (In the past, there have been numerous exceptions to this rule.) Examples:

  - curl_close()

  - mysql_query()

  - PREG_SPLIT_DELIM_CAPTURE

  - new DOMDocument()

  - strpos() (example of a past mistake)

  - new SplFileObject()

- Iterators and Exceptions are however simply postfixed with "`Iterator`" and "`Exception`." Examples:

  - `ArrayIterator`

  - `LogicException`

- PHP reserves all symbols starting with `__` as magical. It is recommended that you do not create symbols starting with `__` in PHP unless you want to use documented magical functionality. Examples:

  - __get()

  - __autoload()

add a note User Contributed Notes
Rules
There are no user contributed notes for this page.
Tips Userland Naming Guide

Last updated: Sat, 27 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 09:32:46 2007 PST