cvs: phpdoc /en/reference/ctype/functions ctype-digit.xml

From: Date: Sun, 22 Feb 2009 21:12:08 +0000
Subject: cvs: phpdoc /en/reference/ctype/functions ctype-digit.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-3327@lists.php.net to get a copy of this message
philip Sun Feb 22 21:12:08 2009 UTC Modified files: /phpdoc/en/reference/ctype/functions ctype-digit.xml Log: Implemented user notes that discuss this returning false when non-strings are passed in... like integers. Added text, example and see also. http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/ctype/functions/ctype-digit.xml?r1=1.9&r2=1.10&diff_format=u Index: phpdoc/en/reference/ctype/functions/ctype-digit.xml diff -u phpdoc/en/reference/ctype/functions/ctype-digit.xml:1.9 phpdoc/en/reference/ctype/functions/ctype-digit.xml:1.10 --- phpdoc/en/reference/ctype/functions/ctype-digit.xml:1.9 Sun Feb 22 20:46:42 2009 +++ phpdoc/en/reference/ctype/functions/ctype-digit.xml Sun Feb 22 21:12:08 2009 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.9 $ --> +<!-- $Revision: 1.10 $ --> <!-- splitted from ./en/functions/ctype.xml, last change in rev 1.1 --> <refentry xml:id="function.ctype-digit" xmlns="http://docbook.org/ns/docbook"> <refnamediv> @@ -14,7 +14,7 @@ <methodparam><type>string</type><parameter>text</parameter></methodparam> </methodsynopsis> <para> - Checks if all of the characters in the provided string, + Checks if all of the characters in the provided <type>string</type>, <parameter>text</parameter>, are numerical. </para> </refsect1> @@ -38,8 +38,8 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - Returns &true; if every character in <parameter>text</parameter> is - a decimal digit, &false; otherwise. + Returns &true; if every character in the <type>string</type> + <parameter>text</parameter> is a decimal digit, &false; otherwise. </para> </refsect1> @@ -97,6 +97,38 @@ </screen> </example> </para> + <para> + <example> + <title>A <function>ctype_digit</function> example comparing strings with integers</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$numeric_string = '42'; +$integer = 42; + +ctype_digit($numeric_string); // true +ctype_digit($integer); // false + +is_numeric($numeric_string); // true +is_numeric($integer); // true +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + This function require a <type>string</type> to be useful, so for example passing + in an <type>integer</type> will always return &false;. However, also note that + HTML Forms will result in numeric strings and not integers. See also the + <link linkend="language.types">types</link> section of the manual. + </para> + </note> </refsect1> <refsect1 role="seealso"> @@ -105,6 +137,9 @@ <simplelist> <member><function>ctype_alnum</function></member> <member><function>ctype_xdigit</function></member> + <member><function>is_numeric</function></member> + <member><function>is_int</function></member> + <member><function>is_string</function></member> </simplelist> </para> </refsect1>

« previous php.doc.cvs (#3327) next »