<HTML ><HEAD ><TITLE >define</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.44"><LINK REL="HOME" TITLE="PHP Manual" HREF="manual.html"><LINK REL="UP" TITLE="Miscellaneous functions" HREF="ref.misc.html"><LINK REL="PREVIOUS" TITLE="connection_timeout" HREF="function.connection-timeout.html"><LINK REL="NEXT" TITLE="defined" HREF="function.defined.html"></HEAD ><BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><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="function.connection-timeout.html" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.defined.html" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.define" >define</A ></H1 ><DIV CLASS="refnamediv" ><A NAME="AEN17234" ></A >define -- Defines a named constant.</DIV ><DIV CLASS="refsect1" ><A NAME="AEN17237" ></A ><H2 >Description</H2 ><DIV CLASS="funcsynopsis" ><P ></P ><CODE CLASS="FUNCDEF" >int define</CODE >(string name, mixed value, int [<SPAN CLASS="optional" >case_insensitive</SPAN >] );<P ></P ></DIV ><P > Defines a named constant, which is similar to a variable except: <P ></P ><UL ><LI ><P > Constants do not have a dollar sign '$' before them; </P ></LI ><LI ><P > Constants may be accessed anywhere without regard to variable scoping rules; </P ></LI ><LI ><P > Constants may not be redefined or undefined once they have been set; and </P ></LI ><LI ><P > Constants may only evaluate to scalar values. </P ></LI ></UL > </P ><P > The name of the constant is given by <TT CLASS="parameter" ><I >name</I ></TT >; the value is given by <TT CLASS="parameter" ><I >value</I ></TT >. </P ><P > The optional third parameter <TT CLASS="parameter" ><I >case_insensitive</I ></TT > is also available. If the value <I CLASS="emphasis" >1</I > is given, then the constant will be defined case-insensitive. The default behaviour is case-sensitive; i.e. CONSTANT and Constant represent different values. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><P ><B >Example 1. Defining Constants</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" WIDTH="100%" ><TR ><TD ><PRE CLASS="programlisting" > 1 2 <?php 3 define ("CONSTANT", "Hello world."); 4 echo CONSTANT; // outputs "Hello world." 5 ?> 6 </PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > <B CLASS="function" >define()</B > returns TRUE on success and FALSE if an error occurs. </P ><P > See also <A HREF="function.defined.html" ><B CLASS="function" >defined()</B ></A > and the section on <A HREF="language.constants.html" >Constants</A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.connection-timeout.html" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="manual.html" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.defined.html" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >connection_timeout</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.misc.html" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >defined</TD ></TR ></TABLE ></DIV ></BODY ></HTML >