<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.is-scalar" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>is_scalar</refname>
  <refpurpose>
   Finds whether a variable is a scalar
  </refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>bool</type><methodname>is_scalar</methodname>
   <methodparam><type>mixed</type><parameter>var</parameter></methodparam>
  </methodsynopsis>
  <para>
   Finds whether the given variable is a scalar.
  </para>
  <para>
   Scalar variables are those containing an <type>integer</type>, 
   <type>float</type>, <type>string</type> or <type>boolean</type>.  
   Types <type>array</type>, <type>object</type> and <type>resource</type> 
   are not scalar.
  </para>
  <note>
   <para>
    <function>is_scalar</function> does not consider <type>resource</type>
    type values to be scalar as resources are abstract datatypes 
    which are currently based on integers. This implementation detail should 
    not be relied upon, as it may change.
   </para>
  </note>
  <note>
   <para>
    <function>is_scalar</function> does not consider NULL to be scalar.
   </para>
  </note>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>var</parameter></term>
     <listitem>
      <para>
       The variable being evaluated.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns &true; if <parameter>var</parameter> is a scalar, &false;
   otherwise.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>is_scalar</function> example</title>
    <programlisting role="php">
<!-- TODO: better example, this one can be quite misleading for unexperienced
           programmers.  -->
<![CDATA[
<?php
function show_var($var) 
{
    if (is_scalar($var)) {
        echo $var;
    } else {
        var_dump($var);
    }
}
$pi = 3.1416;
$proteins = array("hemoglobin", "cytochrome c oxidase", "ferredoxin");

show_var($pi);
show_var($proteins)

?>
]]>
    </programlisting>
    &example.outputs;
    <screen>
<![CDATA[
3.1416
array(3) {
  [0]=>
  string(10) "hemoglobin"
  [1]=>
  string(20) "cytochrome c oxidase"
  [2]=>
  string(10) "ferredoxin"
}
]]>
    </screen>
   </example>
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>is_float</function></member>
    <member><function>is_int</function></member>
    <member><function>is_numeric</function></member>
    <member><function>is_real</function></member>
    <member><function>is_string</function></member>
    <member><function>is_bool</function></member>
    <member><function>is_object</function></member>
    <member><function>is_array</function></member>
   </simplelist>
  </para>
 </refsect1>
</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->