<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.com.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.com-event-sink.php',
    1 => 'com_event_sink',
    2 => 'Connect events from a COM object to a PHP object',
  ),
  'up' => 
  array (
    0 => 'ref.com.php',
    1 => 'COM Функції',
  ),
  'prev' => 
  array (
    0 => 'function.com-create-guid.php',
    1 => 'com_create_guid',
  ),
  'next' => 
  array (
    0 => 'function.com-get-active-object.php',
    1 => 'com_get_active_object',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/com/functions/com-event-sink.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.com-event-sink" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">com_event_sink</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">com_event_sink</span> &mdash; <span class="dc-title">Connect events from a COM object to a PHP object</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.com-event-sink-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>com_event_sink</strong></span>(<span class="methodparam"><span class="type"><a href="class.variant.php" class="type variant">variant</a></span> <code class="parameter">$variant</code></span>, <span class="methodparam"><span class="type"><a href="language.types.object.php" class="type object">object</a></span> <code class="parameter">$sink_object</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</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">$sink_interface</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Instructs COM to sink events generated by
   <code class="parameter">variant</code> into the PHP object
   <code class="parameter">sink_object</code>.
  </p>
  <p class="para">
   Be careful how you use this feature; if you are doing something similar
   to the example below, then it doesn&#039;t really make sense to run it in a
   web server context.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.com-event-sink-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">variant</code></dt>
     <dd>
      <p class="para">
      </p>
     </dd>
    
    
     <dt><code class="parameter">sink_object</code></dt>
     <dd>
      <p class="para">
       <code class="parameter">sink_object</code> should be an instance of a class with
       methods named after those of the desired dispinterface; you may use
       <span class="function"><a href="function.com-print-typeinfo.php" class="function">com_print_typeinfo()</a></span> to help generate a template class
       for this purpose.
      </p>
     </dd>
    
    
     <dt><code class="parameter">sink_interface</code></dt>
     <dd>
      <p class="para">
       PHP will attempt to use the default dispinterface type specified by
       the typelibrary associated with <code class="parameter">variant</code>, but
       you may override this choice by setting
       <code class="parameter">sink_interface</code> to the name of the dispinterface
       that you want to use.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.com-event-sink-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 changelog" id="refsect1-function.com-event-sink-changelog">
  <h3 class="title">Журнал змін</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Версія</th>
      <th>Опис</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">sink_interface</code> is nullable now.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.com-event-sink-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 COM event sink example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">IEEventSinker </span><span style="color: #007700">{<br />    var </span><span style="color: #0000BB">$terminated </span><span style="color: #007700">= </span><span style="color: #0000BB">false</span><span style="color: #007700">;<br /><br />   function </span><span style="color: #0000BB">ProgressChange</span><span style="color: #007700">(</span><span style="color: #0000BB">$progress</span><span style="color: #007700">, </span><span style="color: #0000BB">$progressmax</span><span style="color: #007700">) {<br />      echo </span><span style="color: #DD0000">"Download progress: </span><span style="color: #0000BB">$progress</span><span style="color: #DD0000"> / </span><span style="color: #0000BB">$progressmax</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />    }<br /><br />    function </span><span style="color: #0000BB">DocumentComplete</span><span style="color: #007700">(&amp;</span><span style="color: #0000BB">$dom</span><span style="color: #007700">, </span><span style="color: #0000BB">$url</span><span style="color: #007700">) {<br />      echo </span><span style="color: #DD0000">"Document </span><span style="color: #0000BB">$url</span><span style="color: #DD0000"> complete\n"</span><span style="color: #007700">;<br />    }<br /><br />    function </span><span style="color: #0000BB">OnQuit</span><span style="color: #007700">() {<br />      echo </span><span style="color: #DD0000">"Quit!\n"</span><span style="color: #007700">;<br />      </span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">terminated </span><span style="color: #007700">= </span><span style="color: #0000BB">true</span><span style="color: #007700">;<br />    }<br />}<br /></span><span style="color: #0000BB">$ie </span><span style="color: #007700">= new </span><span style="color: #0000BB">COM</span><span style="color: #007700">(</span><span style="color: #DD0000">"InternetExplorer.Application"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$sink </span><span style="color: #007700">= new </span><span style="color: #0000BB">IEEventSinker</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">com_event_sink</span><span style="color: #007700">(</span><span style="color: #0000BB">$ie</span><span style="color: #007700">, </span><span style="color: #0000BB">$sink</span><span style="color: #007700">, </span><span style="color: #DD0000">"DWebBrowserEvents2"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$ie</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Visible </span><span style="color: #007700">= </span><span style="color: #0000BB">true</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$ie</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">Navigate</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://www.example.org"</span><span style="color: #007700">);<br />while(!</span><span style="color: #0000BB">$sink</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">terminated</span><span style="color: #007700">) {<br />  </span><span style="color: #0000BB">com_message_pump</span><span style="color: #007700">(</span><span style="color: #0000BB">4000</span><span style="color: #007700">);<br />}<br /></span><span style="color: #0000BB">$ie </span><span style="color: #007700">= </span><span style="color: #0000BB">null</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.com-event-sink-notes">
  <h3 class="title">Примітки</h3>
  <div class="caution"><strong class="caution">Застереження</strong>
   <p class="para">
    Prior to PHP 8.0.0, calling <span class="function"><a href="function.exit.php" class="function">exit()</a></span> from any of the event
    handlers is not supported, and may cause PHP to hang. This can be worked around
    by throwing an exception from the event handler, catching the exception in
    the main code, and calling <span class="function"><a href="function.exit.php" class="function">exit()</a></span> from there.
   </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.com-event-sink-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.com-print-typeinfo.php" class="function" rel="rdfs-seeAlso">com_print_typeinfo()</a> - Print out a PHP class definition for a dispatchable interface</span></li>
    <li><span class="function"><a href="function.com-message-pump.php" class="function" rel="rdfs-seeAlso">com_message_pump()</a> - Process COM messages, sleeping for up to timeoutms milliseconds</span></li>
   </ul>
  </p>
 </div>

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