Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > media > main > by-pkgid > 0afeee9cca140e167a996902b9a677c5 > files > 3276

php-manual-en-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>Creating Constants</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK
REL="HOME"
TITLE="PHP Manual"
HREF="index.html"><LINK
REL="UP"
TITLE="Creating Variables"
HREF="zend.variables.html"><LINK
REL="PREVIOUS"
TITLE="Macros for Automatic Global Variable Creation"
HREF="zend.variables.global.html"><LINK
REL="NEXT"
TITLE="Duplicating Variable Contents: The Copy Constructor"
HREF="zend.copy-constructor.html"><META
HTTP-EQUIV="Content-type"
CONTENT="text/html; charset=ISO-8859-1"></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 Manual</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="zend.variables.global.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
>Chapter 33. Creating Variables</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="zend.copy-constructor.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="section"
><H1
CLASS="section"
><A
NAME="zend.variables.constant"
></A
>Creating Constants</H1
><P
>&#13;    Zend supports the creation of true constants (as opposed to
    regular variables). Constants are accessed without the typical
    dollar sign (<TT
CLASS="literal"
>$</TT
>) prefix and are available in all
    scopes. Examples include <TT
CLASS="literal"
>TRUE</TT
> and
    <TT
CLASS="literal"
>FALSE</TT
>, to name just two.
   </P
><P
>&#13;    To create your own constants, you can use the macros in
    <A
HREF="zend.variables.constant.html#tab.create-const"
>Table 33-6</A
>. 
    All the macros create a constant with the specified name and value.
   </P
><P
>&#13;    You can also specify flags for each constant: 
    <P
></P
><UL
><LI
><P
>&#13;       <TT
CLASS="literal"
>CONST_CS</TT
> - This constant's name is to be
       treated as case sensitive.
      </P
></LI
><LI
><P
>&#13;       <TT
CLASS="literal"
>CONST_PERSISTENT</TT
> - This constant is
       persistent and won't be "forgotten" when the current process
       carrying this constant shuts down.
      </P
></LI
></UL
> To use the flags, combine them using a inary OR:
    <TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="programlisting"
>// register a new constant of type "long"
     REGISTER_LONG_CONSTANT("NEW_MEANINGFUL_CONSTANT", 324, CONST_CS |
     CONST_PERSISTENT);</PRE
></TD
></TR
></TABLE
> There are two types of
    macros -      	 	<TT
CLASS="literal"
>REGISTER_*_CONSTANT</TT
>
    and<TT
CLASS="literal"
>REGISTER_MAIN_*_CONSTANT</TT
>. The first type
    creates constants bound to the current module. These constants are
    dumped from the symbol table as soon as the module that registered
    the constant is unloaded from memory. The second type creates
    constants that remain in the symbol table independently of the
    module.
   </P
><DIV
CLASS="table"
><A
NAME="tab.create-const"
></A
><P
><B
>Table 33-6. Macros for Creating Constants</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><TBODY
><TR
><TD
WIDTH="60%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>Macro</TD
><TD
WIDTH="40%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>Description</TD
></TR
><TR
><TD
WIDTH="60%"
ALIGN="LEFT"
VALIGN="MIDDLE"
> 
         <TT
CLASS="literal"
>REGISTER_LONG_CONSTANT(name, value, flags)</TT
>
         <TT
CLASS="literal"
>REGISTER_MAIN_LONG_CONSTANT(name, value, flags)</TT
>
        </TD
><TD
WIDTH="40%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>Registers a new constant of type long.</TD
></TR
><TR
><TD
WIDTH="60%"
ALIGN="LEFT"
VALIGN="MIDDLE"
> 
         <TT
CLASS="literal"
>REGISTER_DOUBLE_CONSTANT(name, value, flags)</TT
>
         <TT
CLASS="literal"
>REGISTER_MAIN_DOUBLE_CONSTANT(name, value, flags)</TT
>
        </TD
><TD
WIDTH="40%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>Registers a new constant of type double.</TD
></TR
><TR
><TD
WIDTH="60%"
ALIGN="LEFT"
VALIGN="MIDDLE"
> 
         <TT
CLASS="literal"
>REGISTER_STRING_CONSTANT(name, value, flags)</TT
>
         <TT
CLASS="literal"
>REGISTER_MAIN_STRING_CONSTANT(name, value, flags)</TT
>
        </TD
><TD
WIDTH="40%"
ALIGN="LEFT"
VALIGN="MIDDLE"
> Registers a new constant of type string. The specified
         string must reside in Zend's internal memory.</TD
></TR
><TR
><TD
WIDTH="60%"
ALIGN="LEFT"
VALIGN="MIDDLE"
> 
         <TT
CLASS="literal"
>REGISTER_STRINGL_CONSTANT(name, value, length, flags)</TT
> 
         <TT
CLASS="literal"
>REGISTER_MAIN_STRINGL_CONSTANT(name, value, length,
          flags)</TT
>
        </TD
><TD
WIDTH="40%"
ALIGN="LEFT"
VALIGN="MIDDLE"
>Registers a new constant of type string. The string length
         is explicitly set to <TT
CLASS="envar"
>length</TT
>. The specified string must reside
         in Zend's internal memory.</TD
></TR
></TBODY
></TABLE
></DIV
></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="zend.variables.global.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="zend.copy-constructor.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>Macros for Automatic Global Variable Creation</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="zend.variables.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Duplicating Variable Contents: The Copy Constructor</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>