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

search for in the

Our source is open

The syntax highlighted source is automatically generated by PHP from the plaintext script. If you're interested in what's behind the several functions we used, you can always take a look at the source of the following files:

Of course, if you want to see the source of this page, we have it available. You can also browse the SVN repository for this website on svn.php.net.

Source of: /manual/en/language.basic-syntax.comments.php

<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once
dirname(__FILE__) ."/toc/language.basic-syntax.inc";
$setup = array (
 
'home' =>
  array (
   
0 => 'index.php',
   
1 => 'PHP Manual',
  ),
 
'head' =>
  array (
   
0 => 'UTF-8',
   
1 => 'en',
  ),
 
'this' =>
  array (
   
0 => 'language.basic-syntax.comments.php',
   
1 => 'Comments',
  ),
 
'up' =>
  array (
   
0 => 'language.basic-syntax.php',
   
1 => 'Basic syntax',
  ),
 
'prev' =>
  array (
   
0 => 'language.basic-syntax.instruction-separation.php',
   
1 => 'Instruction separation',
  ),
 
'next' =>
  array (
   
0 => 'language.types.php',
   
1 => 'Types',
  ),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);

manual_header();
?>
<div id="language.basic-syntax.comments" class="sect1">
   <h2 class="title">Comments</h2>
   <p class="para">
    PHP supports &#039;C&#039;, &#039;C++&#039; and Unix shell-style (Perl style) comments. For example:

    </p><div class="informalexample">
     <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">'This&nbsp;is&nbsp;a&nbsp;test'</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;This&nbsp;is&nbsp;a&nbsp;one-line&nbsp;c++&nbsp;style&nbsp;comment<br />&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;This&nbsp;is&nbsp;a&nbsp;multi&nbsp;line&nbsp;comment<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;yet&nbsp;another&nbsp;line&nbsp;of&nbsp;comment&nbsp;*/<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">echo&nbsp;</span><span style="color: #DD0000">'This&nbsp;is&nbsp;yet&nbsp;another&nbsp;test'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'One&nbsp;Final&nbsp;Test'</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">#&nbsp;This&nbsp;is&nbsp;a&nbsp;one-line&nbsp;shell-style&nbsp;comment<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div><p>
   </p>
   <p class="simpara">
    The &quot;one-line&quot; comment styles only comment to the end of
    the line or the current block of PHP code, whichever comes first.
    This means that HTML code after <i>// ... ?&gt;</i>
    or <i># ...  ?&gt;</i> WILL be printed:
    ?&gt; breaks out of PHP mode and returns to HTML mode, and
    <i>//</i> or <i>#</i> cannot influence that.
    If the <a href="ini.core.php#ini.asp-tags" class="link">asp_tags</a> configuration directive
    is enabled, it behaves the same with <i>// %&gt;</i> and
    <i># %&gt;</i>.
    However, the <i>&lt;/script&gt;</i> tag doesn&#039;t break out of PHP mode in
    a one-line comment.
   </p>
   <p class="para">
    </p><div class="informalexample">
     <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
&lt;h1&gt;This&nbsp;is&nbsp;an&nbsp;<span style="color: #0000BB">&lt;?php&nbsp;</span><span style="color: #FF8000">#&nbsp;echo&nbsp;'simple';</span><span style="color: #0000BB">?&gt;</span>&nbsp;example.&lt;/h1&gt;<br />&lt;p&gt;The&nbsp;header&nbsp;above&nbsp;will&nbsp;say&nbsp;'This&nbsp;is&nbsp;an&nbsp;&nbsp;example'.&lt;/p&gt;</span>
</code></div>
     </div>

    </div><p>
   </p>
   <p class="simpara">
    &#039;C&#039; style comments end at the first <i>*/</i> encountered.
    Make sure you don&#039;t nest &#039;C&#039; style comments.  It is easy to make this
    mistake if you are trying to comment out a large block of code.
   </p>
   <p class="para">
    </p><div class="informalexample">
     <div class="example-contents programlisting">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;</span><span style="color: #FF8000">/*<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;'This&nbsp;is&nbsp;a&nbsp;test';&nbsp;/*&nbsp;This&nbsp;comment&nbsp;will&nbsp;cause&nbsp;a&nbsp;problem&nbsp;*/<br />&nbsp;</span><span style="color: #007700">*/<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </div><p>
   </p>
  </div><?php manual_footer(); ?>
 
show source | credits | sitemap | contact | advertising | mirror sites