<HTML ><HEAD ><TITLE >Comments</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="Basic syntax" HREF="language.basic-syntax.html"><LINK REL="PREVIOUS" TITLE="Instruction separation" HREF="language.basic-syntax.instruction-separation.html"><LINK REL="NEXT" TITLE="Types" HREF="language.types.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="sect1" 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="language.basic-syntax.instruction-separation.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 6. Basic syntax</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="language.types.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="sect1" ><H1 CLASS="sect1" ><A NAME="language.basic-syntax.comments" ></A >Comments</H1 ><P > PHP supports 'C', 'C++' and Unix shell-style comments. For example: <DIV CLASS="informalexample" ><A NAME="AEN3153" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php echo "This is a test"; // This is a one-line c++ style comment /* This is a multi line comment yet another line of comment */ echo "This is yet another test"; echo "One Final Test"; # This is shell-style style comment ?></PRE ></TD ></TR ></TABLE ><P ></P ></DIV > </P ><P > The "one-line" comment styles actually only comment to the end of the line or the current block of PHP code, whichever comes first. </P ><DIV CLASS="informalexample" ><A NAME="AEN3156" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><h1>This is an <?php # echo "simple";?> example.</h1> <p>The header above will say 'This is an example'.</PRE ></TD ></TR ></TABLE ><P ></P ></DIV ><P > You should be careful not to nest 'C' style comments, which can happen when commenting out large blocks. </P ><DIV CLASS="informalexample" ><A NAME="AEN3159" ></A ><P ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php /* echo "This is a test"; /* This comment will cause a problem */ */ ?></PRE ></TD ></TR ></TABLE ><P ></P ></DIV ><P > The one-line comment styles actually only comment to the end of the line or the current block of PHP code, whichever comes first. This means that HTML code after // ?> WILL be printed: ?> skips out of the PHP mode and returns to HTML mode, and // cannot influence that. </P ></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="language.basic-syntax.instruction-separation.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="language.types.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Instruction separation</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="language.basic-syntax.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Types</TD ></TR ></TABLE ></DIV ></BODY ></HTML >