PageRenderTime 1420ms CodeModel.GetById 324ms app.highlight 9ms RepoModel.GetById 307ms app.codeStats 1ms

/php/php-chunked-xhtml/function.settype.html

http://github.com/matsubo/matsu-shell-setting
HTML | 160 lines | 133 code | 27 blank | 0 comment | 0 complexity | 1d8812739f62512f4f56ab4f1c884954 MD5 | raw file
  1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2<html>
  3 <head>
  4  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  5  <title>Set the type of a variable</title>
  6
  7 </head>
  8 <body><div class="manualnavbar" style="text-align: center;">
  9 <div class="prev" style="text-align: left; float: left;"><a href="function.serialize.html">serialize</a></div>
 10 <div class="next" style="text-align: right; float: right;"><a href="function.strval.html">strval</a></div>
 11 <div class="up"><a href="ref.var.html">Variable handling Functions</a></div>
 12 <div class="home"><a href="index.html">PHP Manual</a></div>
 13</div><hr /><div id="function.settype" class="refentry">
 14 <div class="refnamediv">
 15  <h1 class="refname">settype</h1>
 16  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">settype</span> &mdash; <span class="dc-title">Set the type of a variable</span></p>
 17
 18 </div>
 19
 20 <div class="refsect1 description" id="refsect1-function.settype-description">
 21  <h3 class="title">Description</h3>
 22  <div class="methodsynopsis dc-description">
 23   <span class="type">bool</span> <span class="methodname"><b>settype</b></span>
 24    ( <span class="methodparam"><span class="type"><a href="language.pseudo-types.html#language.types.mixed" class="type mixed">mixed</a></span> <tt class="parameter reference">&$var</tt></span>
 25   , <span class="methodparam"><span class="type">string</span> <tt class="parameter">$type</tt></span>
 26   )</div>
 27
 28  <p class="para rdfs-comment">
 29   Set the type of variable <i><tt class="parameter">var</tt></i> to
 30   <i><tt class="parameter">type</tt></i>.
 31  </p>
 32 </div>
 33
 34
 35 <div class="refsect1 parameters" id="refsect1-function.settype-parameters">
 36  <h3 class="title">Parameters</h3>
 37  <p class="para">
 38   <dl>
 39
 40    <dt>
 41
 42     <span class="term"><i><tt class="parameter">var</tt></i></span>
 43     <dd>
 44
 45      <p class="para">
 46       The variable being converted.
 47      </p>
 48     </dd>
 49
 50    </dt>
 51
 52    <dt>
 53
 54     <span class="term"><i><tt class="parameter">type</tt></i></span>
 55     <dd>
 56
 57      <p class="para">
 58       Possibles values of <i><tt class="parameter">type</tt></i> are:
 59       <ul class="itemizedlist">
 60        <li class="listitem">
 61         <span class="simpara">
 62          &quot;boolean&quot; (or, since PHP 4.2.0, &quot;bool&quot;)
 63         </span>
 64        </li>
 65        <li class="listitem">
 66         <span class="simpara">
 67          &quot;integer&quot; (or, since PHP 4.2.0, &quot;int&quot;)
 68         </span>
 69        </li>
 70        <li class="listitem">
 71         <span class="simpara">
 72          &quot;float&quot; (only possible since PHP 4.2.0, for older versions use the
 73          deprecated variant &quot;double&quot;)
 74         </span>
 75        </li>
 76        <li class="listitem">
 77         <span class="simpara">
 78          &quot;string&quot;
 79         </span>
 80        </li>
 81        <li class="listitem">
 82         <span class="simpara">
 83          &quot;array&quot;
 84         </span>
 85        </li>
 86        <li class="listitem">
 87         <span class="simpara">
 88          &quot;object&quot;
 89         </span>
 90        </li>
 91        <li class="listitem">
 92         <span class="simpara">
 93          &quot;null&quot; (since PHP 4.2.0)
 94         </span>
 95        </li>
 96       </ul>
 97      </p>
 98     </dd>
 99
100    </dt>
101
102   </dl>
103
104  </p>
105 </div>
106
107
108 <div class="refsect1 returnvalues" id="refsect1-function.settype-returnvalues">
109  <h3 class="title">Return Values</h3>
110  <p class="para">
111   Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure.
112  </p>
113 </div>
114
115
116 <div class="refsect1 examples" id="refsect1-function.settype-examples">
117  <h3 class="title">Examples</h3>
118  <p class="para">
119   <div class="example" id="example-4491">
120    <p><b>Example #1 <span class="function"><b>settype()</b></span> example</b></p>
121    <div class="example-contents">
122<div class="phpcode"><code><span style="color: #000000">
123<span style="color: #0000BB">&lt;?php<br />$foo&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"5bar"</span><span style="color: #007700">;&nbsp;</span><span style="color: #FF8000">//&nbsp;string<br /></span><span style="color: #0000BB">$bar&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;boolean<br /><br /></span><span style="color: #0000BB">settype</span><span style="color: #007700">(</span><span style="color: #0000BB">$foo</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"integer"</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">//&nbsp;$foo&nbsp;is&nbsp;now&nbsp;5&nbsp;&nbsp;&nbsp;(integer)<br /></span><span style="color: #0000BB">settype</span><span style="color: #007700">(</span><span style="color: #0000BB">$bar</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"string"</span><span style="color: #007700">);&nbsp;&nbsp;</span><span style="color: #FF8000">//&nbsp;$bar&nbsp;is&nbsp;now&nbsp;"1"&nbsp;(string)<br /></span><span style="color: #0000BB">?&gt;</span>
124</span>
125</code></div>
126    </div>
127
128   </div>
129  </p>
130 </div>
131
132
133 <div class="refsect1 notes" id="refsect1-function.settype-notes">
134  <h3 class="title">Notes</h3>
135  <blockquote class="note"><p><b class="note">Note</b>: 
136   <p class="para">
137    Maximum value for &quot;int&quot; is <b><tt>PHP_INT_MAX</tt></b>.
138   </p>
139  </p></blockquote>
140 </div>
141
142
143 <div class="refsect1 seealso" id="refsect1-function.settype-seealso">
144  <h3 class="title">See Also</h3>
145  <p class="para">
146   <ul class="simplelist">
147    <li class="member"><span class="function"><a href="function.gettype.html" class="function" rel="rdfs-seeAlso">gettype()</a> - Get the type of a variable</span></li>
148    <li class="member"><a href="language.types.type-juggling.html#language.types.typecasting" class="link">type-casting</a></li>
149    <li class="member"><a href="language.types.type-juggling.html" class="link">type-juggling</a></li>
150   </ul>
151  </p>
152 </div>
153
154
155</div><hr /><div class="manualnavbar" style="text-align: center;">
156 <div class="prev" style="text-align: left; float: left;"><a href="function.serialize.html">serialize</a></div>
157 <div class="next" style="text-align: right; float: right;"><a href="function.strval.html">strval</a></div>
158 <div class="up"><a href="ref.var.html">Variable handling Functions</a></div>
159 <div class="home"><a href="index.html">PHP Manual</a></div>
160</div></body></html>