<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/reference.pcre.pattern.syntax.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'regexp.reference.comments.php',
    1 => '注释',
    2 => '注释',
  ),
  'up' => 
  array (
    0 => 'reference.pcre.pattern.syntax.php',
    1 => 'PCRE 正则语法',
  ),
  'prev' => 
  array (
    0 => 'regexp.reference.conditional.php',
    1 => '条件子组',
  ),
  'next' => 
  array (
    0 => 'regexp.reference.recursive.php',
    1 => '递归模式',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/pcre/pattern.syntax.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="regexp.reference.comments" class="section">
  <h2 class="title">注释</h2>
  <p class="para">
  字符序列(?#标记开始一个注释直到遇到一个右括号。不允许嵌套括号。
  注释中的字符不会作为模式的一部分参与匹配。
  </p>
  <p class="para">
  如果设置了 <a href="reference.pcre.pattern.modifiers.php" class="link">PCRE_EXTENDED</a> 选项，
  一个字符类外部的未转义的 # 字符就代表本行剩余部分为注释。
  </p>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 PCRE 模式中注释的用法</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$subject </span><span style="color: #007700">= </span><span style="color: #DD0000">'test'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">/* (?# 可用于添加注释而不启用 PCRE_EXTENDED */<br /></span><span style="color: #0000BB">$match </span><span style="color: #007700">= </span><span style="color: #0000BB">preg_match</span><span style="color: #007700">(</span><span style="color: #DD0000">'/te(?# this is a comment)st/'</span><span style="color: #007700">, </span><span style="color: #0000BB">$subject</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$match</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* 除非启用 PCRE_EXTENDED，否则空格和 # 视为模式的一部分 */<br /></span><span style="color: #0000BB">$match </span><span style="color: #007700">= </span><span style="color: #0000BB">preg_match</span><span style="color: #007700">(</span><span style="color: #DD0000">'/te   #~~~~<br />st/'</span><span style="color: #007700">, </span><span style="color: #0000BB">$subject</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$match</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">/* 启用 PCRE_EXTENDED 后，所有空白数据字符以及<br />   同一行未转义的 # 后面的任何内容都将会忽略 */<br /></span><span style="color: #0000BB">$match </span><span style="color: #007700">= </span><span style="color: #0000BB">preg_match</span><span style="color: #007700">(</span><span style="color: #DD0000">'/te    #~~~~<br />st/x'</span><span style="color: #007700">, </span><span style="color: #0000BB">$subject</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$match</span><span style="color: #007700">);</span></span></code></div>
    </div>

    <div class="example-contents"><p>以上示例会输出：</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive cdata"><pre>
int(1)
int(0)
int(1)
</pre></div>
    </div>
   </div>
  </p>
 </div><?php manual_footer($setup); ?>