<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.var.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.floatval.php',
    1 => 'floatval',
    2 => 'Get float value of a variable',
  ),
  'up' => 
  array (
    0 => 'ref.var.php',
    1 => 'Variable handling Functions',
  ),
  'prev' => 
  array (
    0 => 'function.empty.php',
    1 => 'empty',
  ),
  'next' => 
  array (
    0 => 'function.get-debug-type.php',
    1 => 'get_debug_type',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/var/functions/floatval.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.floatval" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">floatval</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">floatval</span> &mdash; <span class="dc-title">Get float value of a variable</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.floatval-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>floatval</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter">$value</code></span>): <span class="type"><a href="language.types.float.php" class="type float">float</a></span></div>

  <p class="para rdfs-comment">
   Gets the <span class="type"><a href="language.types.float.php" class="type float">float</a></span> value of <code class="parameter">value</code>.
  </p>
 </div>

 <div class="refsect1 parameters" id="refsect1-function.floatval-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       May be any scalar type. <span class="function"><strong>floatval()</strong></span> should not be used
       on objects, as doing so will emit an <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> level
       error and return 1.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>

 <div class="refsect1 returnvalues" id="refsect1-function.floatval-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The float value of the given variable. Empty arrays return 0, non-empty
   arrays return 1.
  </p>
  <p class="para">
   Strings will most likely return 0 although this depends on the 
   leftmost characters of the string. The common rules of 
   <a href="language.types.float.php#language.types.float.casting" class="link">float casting</a> 
   apply.
  </p>
 </div>


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

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       The error level when converting from object was changed from <strong><code><a href="errorfunc.constants.php#constant.e-notice">E_NOTICE</a></code></strong> to <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.floatval-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>floatval()</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 />$var </span><span style="color: #007700">= </span><span style="color: #DD0000">'122.34343The'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$float_value_of_var </span><span style="color: #007700">= </span><span style="color: #0000BB">floatval</span><span style="color: #007700">(</span><span style="color: #0000BB">$var</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$float_value_of_var</span><span style="color: #007700">; </span><span style="color: #FF8000">// 122.34343<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Example #2 <span class="function"><strong>floatval()</strong></span> non-numeric leftmost characters Example</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$var </span><span style="color: #007700">= </span><span style="color: #DD0000">'The122.34343'</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$float_value_of_var </span><span style="color: #007700">= </span><span style="color: #0000BB">floatval</span><span style="color: #007700">(</span><span style="color: #0000BB">$var</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$float_value_of_var</span><span style="color: #007700">; </span><span style="color: #FF8000">// 0<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>

 <div class="refsect1 seealso" id="refsect1-function.floatval-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.boolval.php" class="function" rel="rdfs-seeAlso">boolval()</a> - Get the boolean value of a variable</span></li>
    <li><span class="function"><a href="function.intval.php" class="function" rel="rdfs-seeAlso">intval()</a> - Get the integer value of a variable</span></li>
    <li><span class="function"><a href="function.strval.php" class="function" rel="rdfs-seeAlso">strval()</a> - Get string value of a variable</span></li>
    <li><span class="function"><a href="function.settype.php" class="function" rel="rdfs-seeAlso">settype()</a> - Set the type of a variable</span></li>
    <li><a href="language.types.type-juggling.php" class="link">Type juggling</a></li>
   </ul>
  </p>
 </div>

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