Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 3196

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>Gets the properties of the given object</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.get-declared-traits.html">get_declared_traits</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.get-parent-class.html">get_parent_class</a></div>
 <div class="up"><a href="ref.classobj.html">Classes/Object Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.get-object-vars" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">get_object_vars</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">get_object_vars</span> &mdash; <span class="dc-title">Gets the properties of the given object</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.get-object-vars-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>get_object_vars</strong></span>
    ( <span class="methodparam"><span class="type">object</span> <code class="parameter">$object</code></span>
   )</div>

  <p class="para rdfs-comment">
   Gets the accessible non-static properties of the given 
   <em><code class="parameter">object</code></em> according to scope.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.get-object-vars-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">
       An object instance.
      </p>
     </dd>

    </dt>

   </dl>

  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.get-object-vars-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns an associative array of defined object accessible non-static properties 
   for the specified <em><code class="parameter">object</code></em> in scope. If a property has
   not been assigned a value, it will be returned with a <strong><code>NULL</code></strong> value.
  </p>
 </div>

 <div class="refsect1 changelog" id="refsect1-function.get-object-vars-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Description</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>5.3.0</td>
       <td>
        This function now returns <span class="type"><a href="language.types.null.html" class="type NULL">NULL</a></span> if the 
        <em><code class="parameter">object</code></em> isn&#039;t an object. Previously <strong><code>FALSE</code></strong> was returned.
       </td>
      </tr>

      <tr>
       <td>4.2.0</td>
       <td>
        Properties which were declared in the class of the <em><code class="parameter">object</code></em>
        but which weren&#039;t assigned a value are now also returned (with value <strong><code>NULL</code></strong>).
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>

 <div class="refsect1 examples" id="refsect1-function.get-object-vars-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-5055">
    <p><strong>Example #1 Use of  <span class="function"><strong>get_object_vars()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">foo&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;</span><span style="color: #0000BB">$a</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;</span><span style="color: #0000BB">$b&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;</span><span style="color: #0000BB">$c</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;private&nbsp;</span><span style="color: #0000BB">$d</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;static&nbsp;</span><span style="color: #0000BB">$e</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">test</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">get_object_vars</span><span style="color: #007700">(</span><span style="color: #0000BB">$this</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">$test&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">foo</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">get_object_vars</span><span style="color: #007700">(</span><span style="color: #0000BB">$test</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">$test</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">test</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>
array(2) {
  [&quot;b&quot;]=&gt;
  int(1)
  [&quot;c&quot;]=&gt;
  NULL
}
array(4) {
  [&quot;a&quot;]=&gt;
  NULL
  [&quot;b&quot;]=&gt;
  int(1)
  [&quot;c&quot;]=&gt;
  NULL
  [&quot;d&quot;]=&gt;
  NULL
}
</pre></div>
    </div>
   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.get-object-vars-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"> <span class="function"><a href="function.get-class-methods.html" class="function" rel="rdfs-seeAlso">get_class_methods()</a> - Gets the class methods' names</span></li>
    <li class="member"> <span class="function"><a href="function.get-class-vars.html" class="function" rel="rdfs-seeAlso">get_class_vars()</a> - Get the default properties of the class</span></li>
   </ul>
  </p>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.get-declared-traits.html">get_declared_traits</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.get-parent-class.html">get_parent_class</a></div>
 <div class="up"><a href="ref.classobj.html">Classes/Object Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>