<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.reflectionproperty.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'reflectionproperty.gettype.php',
    1 => 'ReflectionProperty::getType',
    2 => 'Gets a property\'s type',
  ),
  'up' => 
  array (
    0 => 'class.reflectionproperty.php',
    1 => 'ReflectionProperty',
  ),
  'prev' => 
  array (
    0 => 'reflectionproperty.getsettabletype.php',
    1 => 'ReflectionProperty::getSettableType',
  ),
  'next' => 
  array (
    0 => 'reflectionproperty.getvalue.php',
    1 => 'ReflectionProperty::getValue',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/reflection/reflectionproperty/gettype.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="reflectionproperty.gettype" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionProperty::getType</h1>
  <p class="verinfo">(PHP 7 &gt;= 7.4.0, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionProperty::getType</span> &mdash; <span class="dc-title">Gets a property&#039;s type</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionproperty.gettype-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionProperty::getType</strong></span>(): <span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="class.reflectiontype.php" class="type ReflectionType">ReflectionType</a></span></span></div>

  <p class="para rdfs-comment">
   Gets the associated type of a property.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionproperty.gettype-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">This function has no parameters.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionproperty.gettype-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns a <span class="classname"><a href="class.reflectiontype.php" class="classname">ReflectionType</a></span> if the property has a type,
   and <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> otherwise.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionproperty.gettype-examples">
  <h3 class="title">Examples</h3>
  <div class="example" id="reflectionproperty.gettype.example.basic">
   <p><strong>Example #1 <span class="methodname"><strong>ReflectionProperty::getType()</strong></span> example</strong></p>
   <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class </span><span style="color: #0000BB">User<br /></span><span style="color: #007700">{<br />    public </span><span style="color: #0000BB">string $name</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$rp </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionProperty</span><span style="color: #007700">(</span><span style="color: #DD0000">'User'</span><span style="color: #007700">, </span><span style="color: #DD0000">'name'</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$rp</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getType</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">getName</span><span style="color: #007700">();<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="annotation-interactive examplescode"><pre class="examplescode">string</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionproperty.gettype-seealso">
  <h3 class="title">See Also</h3>
  <ul class="simplelist">
   <li><span class="methodname"><a href="reflectionproperty.hastype.php" class="methodname" rel="rdfs-seeAlso">ReflectionProperty::hasType()</a> - Checks if property has a type</span></li>
   <li><span class="methodname"><a href="reflectionproperty.isinitialized.php" class="methodname" rel="rdfs-seeAlso">ReflectionProperty::isInitialized()</a> - Checks whether a property is initialized</span></li>
  </ul>
 </div>


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