<?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.strval.php',
    1 => 'strval',
    2 => 'Get string value of a variable',
  ),
  'up' => 
  array (
    0 => 'ref.var.php',
    1 => 'Variable handling Functions',
  ),
  'prev' => 
  array (
    0 => 'function.settype.php',
    1 => 'settype',
  ),
  'next' => 
  array (
    0 => 'function.unserialize.php',
    1 => 'unserialize',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/var/functions/strval.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

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

 </div>
 
 <div class="refsect1 description" id="refsect1-function.strval-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>strval</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.string.php" class="type string">string</a></span></div>

  <p class="simpara">
   Get the string value of a variable.
   See the documentation on <span class="type"><a href="language.types.string.php" class="type string">string</a></span> for more information
   on converting to string.
  </p>
  <p class="simpara">
   This function performs no formatting on the returned value. If you
   are looking for a way to format a numeric value as a string, please
   see <span class="function"><a href="function.sprintf.php" class="function">sprintf()</a></span> or <span class="function"><a href="function.number-format.php" class="function">number_format()</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.strval-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       The variable that is being converted to a <span class="type"><a href="language.types.string.php" class="type string">string</a></span>.
      </p>
      <p class="para">
       <code class="parameter">value</code> may be any scalar type, <span class="type"><a href="language.types.null.php" class="type null">null</a></span>,
       or an <span class="type"><a href="language.types.object.php" class="type object">object</a></span> that implements the <a href="language.oop5.magic.php#object.tostring" class="link">__toString()</a>
       method. You cannot use <span class="function"><strong>strval()</strong></span> on arrays or on
       objects that do not implement the
       <a href="language.oop5.magic.php#object.tostring" class="link">__toString()</a> method.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.strval-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   The <span class="type"><a href="language.types.string.php" class="type string">string</a></span> value of <code class="parameter">value</code>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.strval-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 
     <span class="function"><strong>strval()</strong></span> example using PHP magic
     <a href="language.oop5.magic.php#object.tostring" class="link">__toString()</a> method.
    </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">StrValTest<br /></span><span style="color: #007700">{<br />    public function </span><span style="color: #0000BB">__toString</span><span style="color: #007700">()<br />    {<br />        return </span><span style="color: #0000BB">__CLASS__</span><span style="color: #007700">;<br />    }<br />}<br /><br /></span><span style="color: #FF8000">// Prints 'StrValTest'<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">strval</span><span style="color: #007700">(new </span><span style="color: #0000BB">StrValTest</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-function.strval-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.floatval.php" class="function" rel="rdfs-seeAlso">floatval()</a> - Get float 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.settype.php" class="function" rel="rdfs-seeAlso">settype()</a> - Set the type of a variable</span></li>
    <li><span class="function"><a href="function.sprintf.php" class="function" rel="rdfs-seeAlso">sprintf()</a> - Return a formatted string</span></li>
    <li><span class="function"><a href="function.number-format.php" class="function" rel="rdfs-seeAlso">number_format()</a> - Format a number with grouped thousands</span></li>
    <li><a href="language.types.type-juggling.php" class="link">Type juggling</a></li>
    <li><a href="language.oop5.magic.php#object.tostring" class="link">__toString()</a></li>
   </ul>
  </p>
 </div>


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