Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 6105

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get string value of a variable</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.settype.html">settype</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.unserialize.html">unserialize</a></div>
 <div class="up"><a href="ref.var.html">Variable handling Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.strval" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">strval</h1>
  <p class="verinfo">(PHP 4, PHP 5)</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="type">string</span> <span class="methodname"><strong>strval</strong></span>
    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <code class="parameter">$var</code></span>
   )</div>

  <p class="simpara">
   Get the string value of a variable.
   See the documentation on <span class="type"><a href="language.types.string.html" 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.html" class="function">sprintf()</a></span> or  <span class="function"><a href="function.number-format.html" 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>

     <span class="term"><em><code class="parameter">var</code></em></span>
     <dd>

      <p class="para">
       The variable that is being converted to a <span class="type"><a href="language.types.string.html" class="type string">string</a></span>.
      </p>
      <p class="para">
       <em><code class="parameter">var</code></em> may be any scalar type or an object that
       implements the <a href="language.oop5.magic.html#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.html#object.tostring" class="link">__toString()</a> method.
      </p>
     </dd>

    </dt>

   </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.html" class="type string">string</a></span> value of <em><code class="parameter">var</code></em>.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.strval-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-5273">
    <p><strong>Example #1 
      <span class="function"><strong>strval()</strong></span> example using PHP 5&#039;s magic
     <a href="language.oop5.magic.html#object.tostring" class="link">__toString()</a> method.
    </strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">StrValTest<br /></span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">__toString</span><span style="color: #007700">()<br />&nbsp;&nbsp;&nbsp;&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">__CLASS__</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #FF8000">//&nbsp;Prints&nbsp;'StrValTest'<br /></span><span style="color: #007700">echo&nbsp;</span><span style="color: #0000BB">strval</span><span style="color: #007700">(new&nbsp;</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 class="member"> <span class="function"><a href="function.boolval.html" class="function" rel="rdfs-seeAlso">boolval()</a> - Get the boolean value of a variable</span></li>
    <li class="member"> <span class="function"><a href="function.floatval.html" class="function" rel="rdfs-seeAlso">floatval()</a> - Get float value of a variable</span></li>
    <li class="member"> <span class="function"><a href="function.intval.html" class="function" rel="rdfs-seeAlso">intval()</a> - Get the integer value of a variable</span></li>
    <li class="member"> <span class="function"><a href="function.settype.html" class="function" rel="rdfs-seeAlso">settype()</a> - Set the type of a variable</span></li>
    <li class="member"> <span class="function"><a href="function.sprintf.html" class="function" rel="rdfs-seeAlso">sprintf()</a> - Return a formatted string</span></li>
    <li class="member"> <span class="function"><a href="function.number-format.html" class="function" rel="rdfs-seeAlso">number_format()</a> - Format a number with grouped thousands</span></li>
    <li class="member"><a href="language.types.type-juggling.html" class="link">Type juggling</a></li>
    <li class="member"><a href="language.oop5.magic.html#object.tostring" class="link">__toString()</a></li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.settype.html">settype</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.unserialize.html">unserialize</a></div>
 <div class="up"><a href="ref.var.html">Variable handling Functions</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>