<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Rules</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="Userland Naming Guide" HREF="userlandnaming.html"><LINK REL="PREVIOUS" TITLE="Userland Naming Guide" HREF="userlandnaming.html"><LINK REL="NEXT" TITLE="Tips" HREF="userlandnaming.tips.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="section" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="userlandnaming.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >附录 S. Userland Naming Guide</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="userlandnaming.tips.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="section" ><H1 CLASS="section" ><A NAME="userlandnaming.rules" >Rules</A ></H1 ><P > 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 <A HREF="http://cvs.php.net/viewvc.cgi/php-src/CODING_STANDARDS?view=co" TARGET="_top" >CODING STANDARDS</A >: </P ><P ></P ><UL ><LI ><P > PHP owns the top-level namespace but tries to find decent descriptive names and avoid any obvious clashes. </P ></LI ><LI ><P > Function names use underscores between words, while class names use the camel case rule (there are some exceptions for older classes and functions). </P ></LI ><LI ><P > 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: </P ><P ></P ><UL ><LI ><P ><A HREF="function.curl-close.html" ><B CLASS="function" >curl_close()</B ></A ></P ></LI ><LI ><P ><A HREF="function.mysql-query.html" ><B CLASS="function" >mysql_query()</B ></A ></P ></LI ><LI ><P >PREG_SPLIT_DELIM_CAPTURE</P ></LI ><LI ><P >new DOMDocument()</P ></LI ><LI ><P > <A HREF="function.strpos.html" ><B CLASS="function" >strpos()</B ></A > (example of a past mistake) </P ></LI ><LI ><P >new SplFileObject()</P ></LI ></UL ></LI ><LI ><P > Iterators and Exceptions are however simply postfixed with "<TT CLASS="literal" >Iterator</TT >" and "<TT CLASS="literal" >Exception</TT >." Examples: </P ><P ></P ><UL ><LI ><P ><TT CLASS="literal" >ArrayIterator</TT ></P ></LI ><LI ><P ><TT CLASS="literal" >LogicException</TT ></P ></LI ></UL ></LI ><LI ><P > PHP reserves all symbols starting with <TT CLASS="literal" >__</TT > as magical. It is recommended that you do not create symbols starting with <TT CLASS="literal" >__</TT > in PHP unless you want to use documented magical functionality. Examples: </P ><P ></P ><UL ><LI ><P ><B CLASS="function" >__get()</B ></P ></LI ><LI ><P ><B CLASS="function" >__autoload()</B ></P ></LI ></UL ></LI ></UL ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="userlandnaming.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="userlandnaming.tips.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Userland Naming Guide</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="userlandnaming.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Tips</TD ></TR ></TABLE ></DIV ></BODY ></HTML >