mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-27 22:38:55 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@129424 c90b9560-bf6c-de11-be94-00142212c4b1
102 lines
2.8 KiB
XML
102 lines
2.8 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.3 $ -->
|
|
<!-- splitted from ./en/functions/var.xml, last change in rev 1.35 -->
|
|
<refentry id="function.is-scalar">
|
|
<refnamediv>
|
|
<refname>is_scalar</refname>
|
|
<refpurpose>
|
|
Finds whether a variable is a scalar
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>is_scalar</methodname>
|
|
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>is_scalar</function> returns &true; if the variable
|
|
given by the <parameter>var</parameter> parameter is a scalar,
|
|
otherwise it returns &false;.
|
|
</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>
|
|
or not scalar.
|
|
<informalexample>
|
|
<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);
|
|
// prints: 3.1416
|
|
|
|
show_var($proteins)
|
|
// prints:
|
|
// array(3) {
|
|
// [0]=>
|
|
// string(10) "hemoglobin"
|
|
// [1]=>
|
|
// string(20) "cytochrome c oxidase"
|
|
// [2]=>
|
|
// string(10) "ferredoxin"
|
|
// }
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
</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>
|
|
<para>
|
|
See also <function>is_bool</function>,
|
|
<function>is_numeric</function>,
|
|
<function>is_float</function>,
|
|
<function>is_int</function>,
|
|
<function>is_real</function>,
|
|
<function>is_string</function>,
|
|
<function>is_object</function>,
|
|
<function>is_array</function>, and
|
|
<function>is_integer</function>.
|
|
</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:"../../../../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
|
|
-->
|