<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.closure.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'closure.bind.php',
    1 => 'Closure::bind',
    2 => 'Dupliziert eine Closure mit einem bestimmten gebundenen Objekt und Geltungsbereich einer Klasse',
  ),
  'up' => 
  array (
    0 => 'class.closure.php',
    1 => 'Closure',
  ),
  'prev' => 
  array (
    0 => 'closure.construct.php',
    1 => 'Closure::__construct',
  ),
  'next' => 
  array (
    0 => 'closure.bindto.php',
    1 => 'Closure::bindTo',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'language/predefined/closure/bind.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="closure.bind" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Closure::bind</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.4.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">Closure::bind</span> &mdash; <span class="dc-title">
   Dupliziert eine Closure mit einem bestimmten gebundenen Objekt und Geltungsbereich einer Klasse
  </span></p>

 </div>

 <div class="refsect1 description" id="refsect1-closure.bind-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="modifier">static</span> <span class="methodname"><strong>Closure::bind</strong></span>(<span class="methodparam"><span class="type"><a href="class.closure.php" class="type Closure">Closure</a></span> <code class="parameter">$closure</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.object.php" class="type object">object</a></span></span> <code class="parameter">$newThis</code></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.object.php" class="type object">object</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">$newScope</code><span class="initializer"> = &quot;static&quot;</span></span>): <span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.closure.php" class="type Closure">Closure</a></span></span></div>

  <p class="para rdfs-comment">
   Diese Methode ist die statische Version von
   <span class="methodname"><a href="closure.bindto.php" class="methodname">Closure::bindTo()</a></span>. Siehe die Dokumentation zu dieser
   Methode für weitere Informationen.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-closure.bind-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <dl>
   
    <dt><code class="parameter">closure</code></dt>
    <dd>
     <p class="para">
      Die anonymen Funktionen, die gebunden werden sollen.
     </p>
    </dd>
   
   
    <dt><code class="parameter">newThis</code></dt>
    <dd>
     <p class="para">
      Das Objekt, an das die angegebene anonyme Funktion gebunden werden soll,
      oder <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> wenn die Closure nicht gebunden werden soll.
     </p>
    </dd>
   
   
    <dt><code class="parameter">newScope</code></dt>
    <dd>
     <p class="para">
      Der Geltungsbereich der Klasse, dem die Closure zugeordnet werden soll,
      oder &#039;static&#039;, um den aktuellen Bereich beizubehalten. Wenn ein Objekt
      angegeben wird, wird stattdessen der Typ des Objekts verwendet. Dieser
      bestimmt die Sichtbarkeit der protected und private Methoden des
      gebundenen Objekts. Es ist nicht erlaubt, eine interne Klasse (oder ein
      Objekt einer solchen) als Parameter zu übergeben.
     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-closure.bind-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt ein neues <span class="classname"><a href="class.closure.php" class="classname">Closure</a></span>-Objekt zurück oder <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>,
   wenn ein Fehler auftritt.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-closure.bind-examples">
  <h3 class="title">Beispiele</h3>
  <div class="example" id="example-1">
   <p><strong>Beispiel #1 <span class="function"><strong>Closure::bind()</strong></span>-Beispiel</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">A </span><span style="color: #007700">{<br />    private static </span><span style="color: #0000BB">$sfoo </span><span style="color: #007700">= </span><span style="color: #0000BB">1</span><span style="color: #007700">;<br />    private </span><span style="color: #0000BB">$ifoo </span><span style="color: #007700">= </span><span style="color: #0000BB">2</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">$cl1 </span><span style="color: #007700">= static function() {<br />    return </span><span style="color: #0000BB">A</span><span style="color: #007700">::</span><span style="color: #0000BB">$sfoo</span><span style="color: #007700">;<br />};<br /></span><span style="color: #0000BB">$cl2 </span><span style="color: #007700">= function() {<br />    return </span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">ifoo</span><span style="color: #007700">;<br />};<br /><br /></span><span style="color: #0000BB">$bcl1 </span><span style="color: #007700">= </span><span style="color: #0000BB">Closure</span><span style="color: #007700">::</span><span style="color: #0000BB">bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$cl1</span><span style="color: #007700">, </span><span style="color: #0000BB">null</span><span style="color: #007700">, </span><span style="color: #DD0000">'A'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$bcl2 </span><span style="color: #007700">= </span><span style="color: #0000BB">Closure</span><span style="color: #007700">::</span><span style="color: #0000BB">bind</span><span style="color: #007700">(</span><span style="color: #0000BB">$cl2</span><span style="color: #007700">, new </span><span style="color: #0000BB">A</span><span style="color: #007700">(), </span><span style="color: #DD0000">'A'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$bcl1</span><span style="color: #007700">(), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">$bcl2</span><span style="color: #007700">(), </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt
eine ähnliche Ausgabe wie:</p></div>
   <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">1
2</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-closure.bind-seealso">
  <h3 class="title">Siehe auch</h3>
  <ul class="simplelist">
   <li><a href="functions.anonymous.php" class="link">Anonyme Funktionen</a></li>
   <li><span class="methodname"><a href="closure.bindto.php" class="methodname" rel="rdfs-seeAlso">Closure::bindTo()</a> - Dupliziert eine Closure mit einem neuen gebundenen Objekt und Geltungsbereich einer Klasse</span></li>
  </ul>
 </div>


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