Sophie

Sophie

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

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>The SplInt class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="spltype.construct.html">SplType::__construct</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.splfloat.html">SplFloat</a></div>
 <div class="up"><a href="book.spl-types.html">SPL Types</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.splint" class="reference">

 <h1 class="title">The SplInt class</h1>
 

 <div class="partintro"><p class="verinfo">(PECL spl_types &gt;= 0.1.0)</p>


  <div class="section" id="splint.intro">
   <h2 class="title">Introduction</h2>
   <p class="para">
    The SplInt class is used to enforce strong typing of the integer type.
   </p>
  </div>


  <div class="section" id="splint.synopsis">
   <h2 class="title">Class synopsis</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <strong class="classname">SplInt</strong>
     </span>
     
     <span class="ooclass">
      <span class="modifier">extends</span>
      <a href="class.spltype.html" class="classname">SplType</a>
     </span>
     {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Constants */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">integer</span>
      <var class="fieldsynopsis_varname"><a href="class.splint.html#splint.constants.default"><var class="varname">__default</var></a></var>
     <span class="initializer"> = 0</span>
    ;</div>

    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Inherited methods */</div>
    <div class="methodsynopsis dc-description">
    <span class="methodname"><a href="spltype.construct.html" class="methodname">SplType::__construct</a></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">$initial_value</code></span>
   [, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$strict</code></span>
  ]] )</div>


   }</div>


  </div>
  

  <div class="section" id="splint.constants">
   <h2 class="title">Predefined Constants</h2>
   <dl>


    <dt id="splint.constants.default">
     <span class="term"><strong><code>SplInt::__default</code></strong></span>
     <dd>

      <p class="para"/>
     </dd>

    </dt>


   </dl>

  </div>


 
  <div class="section" id="splint.examples">
   <h2 class="title">Examples</h2>
   <p class="para">
    <div class="example" id="example-3998">
     <p><strong>Example #1 <strong class="classname">SplInt</strong> usage example</strong></p>
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$int&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SplInt</span><span style="color: #007700">(</span><span style="color: #0000BB">94</span><span style="color: #007700">);<br /><br />try&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$int&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">'Try&nbsp;to&nbsp;cast&nbsp;a&nbsp;string&nbsp;value&nbsp;for&nbsp;fun'</span><span style="color: #007700">;<br />}&nbsp;catch&nbsp;(</span><span style="color: #0000BB">UnexpectedValueException&nbsp;$uve</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$uve</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getMessage</span><span style="color: #007700">()&nbsp;.&nbsp;</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br />}<br /><br />echo&nbsp;</span><span style="color: #0000BB">$int&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

     <div class="example-contents"><p>The above example will output:</p></div>
     <div class="example-contents screen">
<div class="cdata"><pre>
Value not an integer
94
</pre></div>
     </div>
    </div>
   </p>
  </div>
 

 </div>

</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="spltype.construct.html">SplType::__construct</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.splfloat.html">SplFloat</a></div>
 <div class="up"><a href="book.spl-types.html">SPL Types</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>