<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.reflectionparameter.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'de',
  ),
  'this' => 
  array (
    0 => 'reflectionparameter.getdefaultvalue.php',
    1 => 'ReflectionParameter::getDefaultValue',
    2 => 'Gets default parameter value',
  ),
  'up' => 
  array (
    0 => 'class.reflectionparameter.php',
    1 => 'ReflectionParameter',
  ),
  'prev' => 
  array (
    0 => 'reflectionparameter.getdeclaringfunction.php',
    1 => 'ReflectionParameter::getDeclaringFunction',
  ),
  'next' => 
  array (
    0 => 'reflectionparameter.getdefaultvalueconstantname.php',
    1 => 'ReflectionParameter::getDefaultValueConstantName',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/reflection/reflectionparameter/getdefaultvalue.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="reflectionparameter.getdefaultvalue" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">ReflectionParameter::getDefaultValue</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.0.3, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">ReflectionParameter::getDefaultValue</span> &mdash; <span class="dc-title">Gets default parameter value</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-reflectionparameter.getdefaultvalue-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>ReflectionParameter::getDefaultValue</strong></span>(): <span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span></div>

  <p class="para rdfs-comment">
   Gets the default value of the parameter for any user-defined or internal function or method.
   If the parameter is not optional a <span class="classname"><a href="class.reflectionexception.php" class="classname">ReflectionException</a></span>
   will be thrown.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-reflectionparameter.getdefaultvalue-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">Diese Funktion besitzt keine Parameter.</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-reflectionparameter.getdefaultvalue-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   The parameters default value.
  </p>
 </div>

 
 <div class="refsect1 changelog" id="refsect1-reflectionparameter.getdefaultvalue-changelog">
  <h3 class="title">Changelog</h3>
  <p class="para">
   <table class="doctable informaltable">
    
     <thead>
      <tr>
       <th>Version</th>
       <th>Beschreibung</th>
      </tr>

     </thead>

     <tbody class="tbody">
      <tr>
       <td>8.0.0</td>
       <td>
        This method now allows getting the default value of parameters of built-in functions and
        built-in class methods. Previously, a <span class="classname"><a href="class.reflectionexception.php" class="classname">ReflectionException</a></span> was thrown.
       </td>
      </tr>

     </tbody>
    
   </table>

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-reflectionparameter.getdefaultvalue-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 Getting default values of function parameters</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">function </span><span style="color: #0000BB">foo</span><span style="color: #007700">(</span><span style="color: #0000BB">$test</span><span style="color: #007700">, </span><span style="color: #0000BB">$bar </span><span style="color: #007700">= </span><span style="color: #DD0000">'baz'</span><span style="color: #007700">)<br />{<br />    echo </span><span style="color: #0000BB">$test </span><span style="color: #007700">. </span><span style="color: #0000BB">$bar</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">$function </span><span style="color: #007700">= new </span><span style="color: #0000BB">ReflectionFunction</span><span style="color: #007700">(</span><span style="color: #DD0000">'foo'</span><span style="color: #007700">);<br /><br />foreach (</span><span style="color: #0000BB">$function</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getParameters</span><span style="color: #007700">() as </span><span style="color: #0000BB">$param</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">'Name: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$param</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getName</span><span style="color: #007700">() . </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />    if (</span><span style="color: #0000BB">$param</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">isOptional</span><span style="color: #007700">()) {<br />        echo </span><span style="color: #DD0000">'Default value: ' </span><span style="color: #007700">. </span><span style="color: #0000BB">$param</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getDefaultValue</span><span style="color: #007700">() . </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />    }<br />    echo </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
   <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Name: test

Name: bar
Default value: baz</pre>
</div>
   </div>
   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-reflectionparameter.getdefaultvalue-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="methodname"><a href="reflectionparameter.isoptional.php" class="methodname" rel="rdfs-seeAlso">ReflectionParameter::isOptional()</a> - Checks if optional</span></li>
    <li><span class="methodname"><a href="reflectionparameter.isdefaultvalueavailable.php" class="methodname" rel="rdfs-seeAlso">ReflectionParameter::isDefaultValueAvailable()</a> - Checks if a default value is available</span></li>
    <li><span class="methodname"><a href="reflectionparameter.getdefaultvalueconstantname.php" class="methodname" rel="rdfs-seeAlso">ReflectionParameter::getDefaultValueConstantName()</a> - Returns the default value's constant name if default value is constant or null</span></li>
    <li><span class="methodname"><a href="reflectionparameter.ispassedbyreference.php" class="methodname" rel="rdfs-seeAlso">ReflectionParameter::isPassedByReference()</a> - Checks if passed by reference</span></li>
   </ul>
  </p>
 </div>


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