<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.xml.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.xml-parser-set-option.php',
    1 => 'xml_parser_set_option',
    2 => '在 XML 解析器中设置选项',
  ),
  'up' => 
  array (
    0 => 'ref.xml.php',
    1 => 'XML 解析器函数',
  ),
  'prev' => 
  array (
    0 => 'function.xml-parser-get-option.php',
    1 => 'xml_parser_get_option',
  ),
  'next' => 
  array (
    0 => 'function.xml-set-character-data-handler.php',
    1 => 'xml_set_character_data_handler',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/xml/functions/xml-parser-set-option.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.xml-parser-set-option" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">xml_parser_set_option</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">xml_parser_set_option</span> &mdash; <span class="dc-title">在 XML 解析器中设置选项</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.xml-parser-set-option-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>xml_parser_set_option</strong></span>(<span class="methodparam"><span class="type"><a href="class.xmlparser.php" class="type XMLParser">XMLParser</a></span> <code class="parameter">$parser</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$option</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></span> <code class="parameter">$value</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   在 XML 解析器中设置选项。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.xml-parser-set-option-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">parser</code></dt>
     <dd>
      <p class="para">
       指向要设置选项的 XML 解析器。
      </p>
     </dd>
    
    
     <dt><code class="parameter">option</code></dt>
     <dd>
      <p class="para">
       要设置的选项。见下文。
      </p>
      <p class="para">
       以下选项可用：
       <table class="doctable table">
        <caption><strong>XML 解析器选项</strong></caption>
        
         <thead>
          <tr>
           <th>选项常量</th>
           <th>数据类型</th>
           <th>说明</th>
          </tr>

         </thead>

         <tbody class="tbody">
          <tr>
           <td><strong><code><a href="xml.constants.php#constant.xml-option-case-folding">XML_OPTION_CASE_FOLDING</a></code></strong></td>
           <td>bool</td>
           <td>
            控制是否为此 XML 解析器启用<a href="xml.case-folding.php" class="link">大写转换</a>。默认启用。
           </td>
          </tr>

          <tr>
           <td><strong><code><a href="xml.constants.php#constant.xml-option-parse-huge">XML_OPTION_PARSE_HUGE</a></code></strong></td>
           <td>bool</td>
           <td>
            允许解析大于 10 MB 的文档。
            仅当文档大小有限时才应启用此选项，否则可能导致 DoS。
            仅在使用 libxml2 时才可用。
           </td>
          </tr>

          <tr>
           <td><strong><code><a href="xml.constants.php#constant.xml-option-skip-tagstart">XML_OPTION_SKIP_TAGSTART</a></code></strong></td>
           <td>integer</td> 
           <td>
            指定在标记名称的开头应略过多少个字符。
           </td>
          </tr>

          <tr>
           <td><strong><code><a href="xml.constants.php#constant.xml-option-skip-white">XML_OPTION_SKIP_WHITE</a></code></strong></td>
           <td>bool</td> 
           <td>
            是否略过由空白字符组成的值。
           </td>
          </tr>

          <tr>
           <td><strong><code><a href="xml.constants.php#constant.xml-option-target-encoding">XML_OPTION_TARGET_ENCODING</a></code></strong></td>
           <td>string</td> 
           <td>
            设置要在此 XML 解析器中使用的<a href="xml.encoding.php" class="link">目标编码</a>。默认情况下，设置的编码与 <span class="function"><a href="function.xml-parser-create.php" class="function">xml_parser_create()</a></span>
            使用的源编码相同。支持的目标编码有 <code class="literal">ISO-8859-1</code>、<code class="literal">US-ASCII</code> 和 <code class="literal">UTF-8</code>。
           </td>
          </tr>

         </tbody>
        
       </table>

      </p>
     </dd>
    
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       选项的新值。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.xml-parser-set-option-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   成功时返回 <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>，失败时返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.xml-parser-set-option-errors">
  <h3 class="title">错误／异常</h3>
  <p class="para">
   当传递到 <code class="parameter">option</code> 的值无效时抛出 <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span>。
  </p>
  <p class="para">
   在 PHP 8.0.0 之前，向 <code class="parameter">option</code> 传递的值无效时会生成
   <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> 并使函数返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.xml-parser-set-option-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.4.0</td>
      <td>
       添加了选项 <strong><code><a href="xml.constants.php#constant.xml-option-parse-huge">XML_OPTION_PARSE_HUGE</a></code></strong>。
      </td>
     </tr>

     <tr>
      <td>8.3.0</td>
      <td>
       <code class="parameter">value</code> 参数现在也接受 bool。选项 <strong><code><a href="xml.constants.php#constant.xml-option-case-folding">XML_OPTION_CASE_FOLDING</a></code></strong> 和
       <strong><code><a href="xml.constants.php#constant.xml-option-skip-white">XML_OPTION_SKIP_WHITE</a></code></strong> 现在是 bool 选项。
      </td>
     </tr>

     <tr>
 <td>8.0.0</td>
 <td>
  <code class="parameter">parser</code> 现在接受 <span class="classname"><a href="class.xmlparser.php" class="classname">XMLParser</a></span> 实例；之前接受有效的 <code class="literal">xml</code> <span class="type"><a href="language.types.resource.php" class="type resource">resource</a></span>。
 </td>
</tr>

     <tr>
      <td>8.0.0</td>
      <td>
       如果 <code class="parameter">option</code> 无效，现在抛出 <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span>。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


</div><?php manual_footer($setup); ?>