philip Mon Mar 28 04:06:35 2005 EDT
Modified files: /phpdoc/en/reference/var/functions intval.xml Log: Rewrote docs, and added examples. Implemented User Notes and closes bug #32294. Expanded the return value section and added new SeeAlso's. Used new doc style. http://cvs.php.net/diff.php/phpdoc/en/reference/var/functions/intval.xml?r1=1.3&r2=1.4&ty=u Index: phpdoc/en/reference/var/functions/intval.xml diff -u phpdoc/en/reference/var/functions/intval.xml:1.3 phpdoc/en/reference/var/functions/intval.xml:1.4 --- phpdoc/en/reference/var/functions/intval.xml:1.3 Tue Mar 15 08:54:27 2005 +++ phpdoc/en/reference/var/functions/intval.xml Mon Mar 28 04:06:34 2005 @@ -1,44 +1,128 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.3 $ --> -<!-- splitted from ./en/functions/var.xml, last change in rev 1.2 --> - <refentry id="function.intval"> - <refnamediv> - <refname>intval</refname> - <refpurpose>Get integer value of a variable</refpurpose> - </refnamediv> - <refsect1> - <title>Description</title> - <methodsynopsis> - <type>int</type><methodname>intval</methodname> - <methodparam><type>mixed</type><parameter>var</parameter></methodparam> - <methodparam choice="opt"><type>int</type><parameter>base</parameter></methodparam> - </methodsynopsis> - <simpara> - Returns the <type>integer</type> value of <parameter>var</parameter>, - using the specified base for the conversion (the default is - base 10). - </simpara> - <simpara> - <parameter>var</parameter> may be any scalar type. You cannot use - <function>intval</function> on <type>array</type>s or <type>object</type>s. - Common rules of <link linkend="language.types.integer.casting">converting - to integer</link> apply. - </simpara> - <note> - <para> - The <parameter>base</parameter> argument for - <function>intval</function> has no effect unless the - <parameter>var</parameter> argument is a string. - </para> - </note> - <simpara> - See also <function>floatval</function>, - <function>strval</function>, <function>settype</function> and - <link linkend="language.types.type-juggling">Type - juggling</link>. - </simpara> - </refsect1> - </refentry> +<!-- $Revision: 1.4 $ --> +<refentry id="function.intval"> + <refnamediv> + <refname>intval</refname> + <refpurpose>Get the integer value of a variable</refpurpose> + </refnamediv> + + <refsect1 role="description"> + &reftitle.description; + <methodsynopsis> + <type>int</type><methodname>intval</methodname> + <methodparam><type>mixed</type><parameter>var</parameter></methodparam> + <methodparam choice="opt"><type>int</type><parameter>base</parameter></methodparam> + </methodsynopsis> + <para> + Returns the <type>integer</type> value of <parameter>var</parameter>, + using the specified <parameter>base</parameter> for the conversion + (the default is base 10). + </para> + </refsect1> + + <refsect1 role="parameters"> + &reftitle.parameters; + <para> + <variablelist> + <varlistentry> + <term><parameter>var</parameter></term> + <listitem> + <para> + The scalar value being converted to an integer + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>base</parameter></term> + <listitem> + <para> + The base for the conversion (default is base 10) + </para> + </listitem> + </varlistentry> + </variablelist> + </para> + </refsect1> + + <refsect1 role="returnvalues"> + &reftitle.returnvalues; + <para> + The integer value of <parameter>var</parameter> on success, or 0 on + failure. Empty arrays and objects return 0, non-empty arrays and + objects return 1. + </para> + <para> + The maximum value depends on the system. 32 bit systems have a + maximum signed integer range of -2147483648 to 2147483647. So for example + on such a system, <literal>intval('1000000000000')</literal> will return + 2147483647. The maximum signed integer value for 64 bit systems is + 9223372036854775807. + </para> + <para> + Strings will most likely return 0 although this depends on the + leftmost characters of the string. The common rules of + <link linkend="language.types.integer.casting">integer casting</link> + apply. + </para> + </refsect1> + + <refsect1 role="examples"> + &reftitle.examples; + <para> + <example> + <title><function>intval</function> examples</title> + <para> + The following examples are based on a 32 bit system. + </para> + <programlisting role="php"> +<![CDATA[ +<?php +echo intval(42); // 42 +echo intval(4.2); // 4 +echo intval('42'); // 42 +echo intval('+42'); // 42 +echo intval('-42'); // -42 +echo intval(042); // 34 +echo intval('042'); // 42 +echo intval(1e10); // 1410065408 +echo intval('1e10'); // 1 +echo intval(0x1A); // 26 +echo intval(42000000); // 42000000 +echo intval(420000000000000000000); // 0 +echo intval('420000000000000000000'); // 2147483647 +echo intval(42, 8); // 42 +echo intval('42', 8); // 34 +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + The <parameter>base</parameter> parameter has no effect unless the + <parameter>var</parameter> parameter is a string. + </para> + </note> + </refsect1> + + <refsect1 role="seealso"> + &reftitle.seealso; + <para> + <simplelist> + <member><function>floatval</function></member> + <member><function>strval</function></member> + <member><function>settype</function></member> + <member><function>is_numeric</function></member> + <member><link linkend="language.types.type-juggling">Type juggling</link></member> + <member><link linkend="ref.bc">BCMath Arbitrary Precision Mathematics Functions</link></member> + </simplelist> + </para> + </refsect1> +</refentry> <!-- Keep this comment at the end of the file Local variables: