<?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 => 'uk',
  ),
  'this' => 
  array (
    0 => 'reflectionproperty.hasdefaultvalue.php',
    1 => 'ReflectionProperty::hasDefaultValue',
    2 => 'Checks if property has a default value declared',
  ),
  'up' => 
  array (
    0 => 'class.reflectionproperty.php',
    1 => 'ReflectionProperty',
  ),
  'prev' => 
  array (
    0 => 'reflectionproperty.getvalue.php',
    1 => 'ReflectionProperty::getValue',
  ),
  'next' => 
  array (
    0 => 'reflectionproperty.hashook.php',
    1 => 'ReflectionProperty::hasHook',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/reflection/reflectionproperty/hasdefaultvalue.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="reflectionproperty.hasdefaultvalue" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionProperty::hasDefaultValue</h1>
  <p class="verinfo">(PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionProperty::hasDefaultValue</span> &mdash; <span class="dc-title">Checks if property has a default value declared</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionproperty.hasdefaultvalue-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionProperty::hasDefaultValue</strong></span>(): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   Checks whether the property was declared with a default value, including an implicit
   <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong> default value. Only returns <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> for typed properties without default value (or
   dynamic properties).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionproperty.hasdefaultvalue-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">У цієї функції немає
параметрів.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionproperty.hasdefaultvalue-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   If the property has any default value (including <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>) <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> is returned;
   if the property is typed without a default value declared or is a dynamic property, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> is returned.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionproperty.hasdefaultvalue-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
 <p><strong>Приклад #1 <span class="methodname"><strong>ReflectionProperty::hasDefaultValue()</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">Foo </span><span style="color: #007700">{<br />    public </span><span style="color: #0000BB">$bar</span><span style="color: #007700">;<br />    public ?</span><span style="color: #0000BB">int $baz</span><span style="color: #007700">;<br />    public ?</span><span style="color: #0000BB">int $foo </span><span style="color: #007700">= </span><span style="color: #0000BB">null</span><span style="color: #007700">;<br />    public </span><span style="color: #0000BB">int $boing</span><span style="color: #007700">;<br />    <br />    public function </span><span style="color: #0000BB">__construct</span><span style="color: #007700">()<br />    {<br />        </span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">ping </span><span style="color: #007700">= </span><span style="color: #DD0000">''</span><span style="color: #007700">;<br />    }<br />}<br /><br /></span><span style="color: #0000BB">$ro </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionObject</span><span style="color: #007700">(new </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">$ro</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getProperty</span><span style="color: #007700">(</span><span style="color: #DD0000">'bar'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">hasDefaultValue</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$ro</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getProperty</span><span style="color: #007700">(</span><span style="color: #DD0000">'baz'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">hasDefaultValue</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$ro</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getProperty</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">hasDefaultValue</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$ro</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getProperty</span><span style="color: #007700">(</span><span style="color: #DD0000">'boing'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">hasDefaultValue</span><span style="color: #007700">());<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$ro</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getProperty</span><span style="color: #007700">(</span><span style="color: #DD0000">'ping'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">hasDefaultValue</span><span style="color: #007700">()); </span><span style="color: #FF8000">// Dynamic property<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$ro</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getProperty</span><span style="color: #007700">(</span><span style="color: #DD0000">'pong'</span><span style="color: #007700">)-&gt;</span><span style="color: #0000BB">hasDefaultValue</span><span style="color: #007700">()); </span><span style="color: #FF8000">// Not defined property<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
 </div>

 <div class="example-contents"><p>Поданий вище приклад
виведе:</p></div>
 <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">bool(true)
bool(false)
bool(true)
bool(false)
bool(false)

Fatal error: Uncaught ReflectionException: Property Foo::$pong does not exist in example.php</pre>
</div>
 </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-reflectionproperty.hasdefaultvalue-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
 <li><span class="methodname"><a href="reflectionproperty.getdefaultvalue.php" class="methodname" rel="rdfs-seeAlso">ReflectionProperty::getDefaultValue()</a> - Returns the default value declared for a property</span></li>
   </ul>
  </p>
 </div>


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