Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 12587

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Constructs a new weak reference</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="weakref.acquire.html">Weakref::acquire</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="weakref.get.html">Weakref::get</a></div>
 <div class="up"><a href="class.weakref.html">WeakRef</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="weakref.construct" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Weakref::__construct</h1>
  <p class="verinfo">(PECL weakref &gt;= 0.1.0)</p><p class="refpurpose"><span class="refname">Weakref::__construct</span> &mdash; <span class="dc-title">Constructs a new weak reference</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-weakref.construct-description">
  <h3 class="title">Description</h3>
  <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span>  <span class="methodname"><strong>Weakref::__construct()</strong></span>
    ([ <span class="methodparam"><span class="type">object</span> <code class="parameter">$object</code></span>
  ] )</div>

  <p class="para rdfs-comment">
   Constructs a new weak reference.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-weakref.construct-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>

    <dt>

     <span class="term"><em><code class="parameter">object</code></em></span>
     <dd>

      <p class="para">
       The object to reference.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-weakref.construct-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   No value is returned.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-weakref.construct-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-551">
    <p><strong>Example #1  <span class="methodname"><strong>Weakref::__construct()</strong></span> 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&nbsp;</span><span style="color: #0000BB">MyClass&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">__destruct</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Destroying&nbsp;object!\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$o1&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">MyClass</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$r1&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">Weakref</span><span style="color: #007700">(</span><span style="color: #0000BB">$o1</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">$r1</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">valid</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Object&nbsp;still&nbsp;exists!\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$r1</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">());<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Object&nbsp;is&nbsp;dead!\n"</span><span style="color: #007700">;<br />}<br /><br />unset(</span><span style="color: #0000BB">$o1</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">$r1</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">valid</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Object&nbsp;still&nbsp;exists!\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$r1</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">get</span><span style="color: #007700">());<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Object&nbsp;is&nbsp;dead!\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>The above example will output:</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Object still exists!
object(MyClass)#1 (0) {
}
Destroying object!
Object is dead!
</pre></div>
    </div>
   </div>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="weakref.acquire.html">Weakref::acquire</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="weakref.get.html">Weakref::get</a></div>
 <div class="up"><a href="class.weakref.html">WeakRef</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>