<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.xml-set-processing-instruction-handler.php',
    1 => 'xml_set_processing_instruction_handler',
    2 => '処理命令 (PI) 用ハンドラを設定する',
  ),
  'up' => 
  array (
    0 => 'ref.xml.php',
    1 => 'XML パーサー 関数',
  ),
  'prev' => 
  array (
    0 => 'function.xml-set-object.php',
    1 => 'xml_set_object',
  ),
  'next' => 
  array (
    0 => 'function.xml-set-start-namespace-decl-handler.php',
    1 => 'xml_set_start_namespace_decl_handler',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    'path' => 'reference/xml/functions/xml-set-processing-instruction-handler.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.xml-set-processing-instruction-handler" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">xml_set_processing_instruction_handler</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">xml_set_processing_instruction_handler</span> &mdash; <span class="dc-title">
   処理命令 (PI) 用ハンドラを設定する
  </span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.xml-set-processing-instruction-handler-description">
  <h3 class="title">説明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>xml_set_processing_instruction_handler</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"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span>|<span class="type"><a href="language.types.null.php" class="type null">null</a></span></span> <code class="parameter">$handler</code></span>): <span class="type"><a href="language.types.singleton.php" class="type true">true</a></span></div>

  <p class="para rdfs-comment">
   XML パーサー <code class="parameter">parser</code>の処理命令 (PI) 用ハンドラ関数を設定します。
  </p>
  <p class="para">
   処理命令のフォーマットは以下のとおりです:
   <div class="example-contents">
<div class="annotation-interactive xmlcode"><pre class="xmlcode">&lt;?target
data
?&gt;</pre>
</div>
   </div>

  </p>
  <div class="caution"><strong class="caution">警告</strong>
   <p class="para">
    PHP コードは、処理命令 <code class="literal">&lt;?php</code> によって区切られます。
    よって、XMLドキュメントに PHP コードを入れることが可能です。
    しかし、PI 終了タグ (<code class="literal">?&gt;</code>) をデータに含めてはいけません。
    PI 終了タグ が埋め込まれたPHPコードの一部として存在していた場合、
    残りの PHP コードは、&quot;真の&quot; PI 終了タグと同じく文字データとして処理されます。
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.xml-set-processing-instruction-handler-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">handler</code></dt>
     <dd>
      <p class="para">
 <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> が渡されると、ハンドラはデフォルトの状態にリセットされます。
 <div class="warning"><strong class="warning">警告</strong>
  <p class="simpara">
   空文字列を渡すことでもハンドラはリセットされますが、これは PHP 8.4.0 以降非推奨となっています。
  </p>
 </div>
</p>
<p class="para">
 <code class="parameter">handler</code> が <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> の場合、その callable がハンドラとして設定されます。
</p>
<p class="para">
 <code class="parameter">handler</code> が文字列の場合、<span class="function"><a href="function.xml-set-object.php" class="function">xml_set_object()</a></span> で設定されたオブジェクトのメソッド名になります。
 <div class="warning"><strong class="warning">警告</strong>
  <p class="simpara">
   PHP 8.4.0 以降、非推奨となっています。
  </p>
 </div>
</p>
<div class="warning"><strong class="warning">警告</strong>
 <p class="simpara">
  PHP 8.4.0 以降では、実際に呼び出されるときではなく、ハンドラを設定する際に callable であるかがチェックされます。
  従って、コールバックとしてメソッド文字列を指定する場合、それより前に、 <span class="function"><a href="function.xml-set-object.php" class="function">xml_set_object()</a></span> を呼び出しておく必要があります。
  しかし、この動作も PHP 8.4.0 以降非推奨となっているため、メソッドには適切な <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> を使用することが推奨されます。
 </p>
</div>

      <p class="para">
       <code class="parameter">handler</code> のシグネチャは、下記でなければいけません: 
       <div class="methodsynopsis dc-description"><span class="methodname"><span class="replaceable">handler</span></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.string.php" class="type string">string</a></span> <code class="parameter">$target</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$data</code></span>): <span class="type"><a href="language.types.void.php" class="type void">void</a></span></div>

       <dl>
        
 <dt><code class="parameter">parser</code></dt>
 <dd>
  <span class="simpara">
   ハンドラをコールするXMLパーサー
  </span>
 </dd>

        
         <dt><code class="parameter">target</code></dt>
         <dd>
          <span class="simpara">
           処理命令のターゲット
          </span>
         </dd>
        
        
         <dt><code class="parameter">data</code></dt>
         <dd>
          <span class="simpara">
           処理命令のデータ
          </span>
         </dd>
        
       </dl>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.xml-set-processing-instruction-handler-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   常に <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> を返します。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.xml-set-processing-instruction-handler-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>
  非 <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> な <span class="type"><a href="language.types.string.php" class="type string">string</a></span> を <code class="parameter">handler</code> に渡すことは、現在非推奨となっています。
  メソッドには適切な callable を使用するか、ハンドラをリセットする場合は <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> を使用してください。
 </td>
</tr>

<tr>
 <td>8.4.0</td>
 <td>
  <code class="parameter">handler</code> が <span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> として有効であるかどうかは、
  呼び出し時ではなく、ハンドラーを設定する際にチェックされるようになりました。
 </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>

    </tbody>
   
  </table>

 </div>


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