hholzgra Sat Oct 26 02:58:17 2002 EDT Modified files: /phpdoc/en/language types.xml /phpdoc/en/reference/array/functions usort.xml Log: - documentation on pseudo-types - "callback" pseudo-type added - changed usort proto to use callback (more will follow) Index: phpdoc/en/language/types.xml diff -u phpdoc/en/language/types.xml:1.88 phpdoc/en/language/types.xml:1.89 --- phpdoc/en/language/types.xml:1.88 Wed Sep 18 09:38:04 2002 +++ phpdoc/en/language/types.xml Sat Oct 26 02:58:16 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.88 $ --> +<!-- $Revision: 1.89 $ --> <chapter id="language.types"> <title>Types</title> @@ -77,27 +77,35 @@ </listitem> </itemizedlist> + + This manual also introduces some + <link linkend="language.pseudo-types">pseudo-types</link> + for readability reasons: + + <itemizedlist> + + <listitem> + <simpara> + <link linkend="language.types.mixed">mixed</link> + </simpara> + </listitem> + + <listitem> + <simpara> + <link linkend="language.types.number">number</link> + </simpara> + </listitem> + + <listitem> + <simpara> + <link linkend="language.types.mixed">callback</link> + </simpara> + </listitem> + + </itemizedlist> + </para> - <note> - <simpara> - In this manual you'll often find <literal>mixed</literal> parameters. - This pseudo-type - indicates multiple possibilities for that parameter. - </simpara> - <!-- - - Just an idea, maybe useful for some func-defs? - (at least it is for the operator-defs) - - <simpara> - In parameter definitions you can also encounter the 'number' pseudo-type, - that indicates a parameter that is either <type>integer</type> or - <type>float</type>. - </simpara> - --> - </note> - <simpara> The type of a variable is usually not set by the programmer; @@ -1827,7 +1835,89 @@ See also <function>is_null</function> and <function>unset</function>. </para> </sect2> + </sect1> + + <sect1 id="language.pseudo-types"> + <title>Pseudo-types used in this documentation</title> + + <sect2 id="language.types.mixed"> + <title>mixed</title> + <para> + <literal>mixed</literal> indicates that a parameter may accept multiple (but not + necesseraly all) types. + </para> + <para> + <function>gettype</function> for example will accept all PHP types, + while <function>str_replace</function> will accept strings and arrays. + </para> + </sect2> + <sect2 id="language.types.number"> + <title>number</title> + <para> + <literal>number</literal> indicates that a parameter can be either + <type>integer</type> or <type>float</type>. + </para> + </sect2> + + <sect2 id="language.types.callback"> + <title>callback</title> + <para> + Some functions like <function>call_user_function</function> + or <function>usort</function> accept user defined + callback functions as a parameter. Callback functions can not only + be simple functions but also object methods including static class + methods. + </para> + <para> + A PHP function is simply passed by its name as a string. + </para> + <para> + A method of an instantiated object is passed as an array containing + an object as the element with index 0 and a method name as the + element with index 1. + </para> + <para> + Static class methods can also be passed without instantiating an + object of that class by passing the class name instead of an + object as the element with index 0. + </para> + + <para> + <example> + <title> + Callback function examples + </title> + <programlisting role="php"> +<![CDATA[ +<?php + +// simple callback example +function foobar() { + echo "hello world!"; +} +call_user_function("foobar"); + +// method callback examples +class foo { + function bar() { + echo "hello world!"; + } +} + +$foo = new foo; + +call_user_function(array($foo, "bar")); // object method call + +call_user_function(array("foo", "bar")); // static class method call + +?> +]]> + </programlisting> + </example> + </para> + + </sect2> </sect1> <sect1 id="language.types.type-juggling"> Index: phpdoc/en/reference/array/functions/usort.xml diff -u phpdoc/en/reference/array/functions/usort.xml:1.6 phpdoc/en/reference/array/functions/usort.xml:1.7 --- phpdoc/en/reference/array/functions/usort.xml:1.6 Mon Jun 17 11:34:33 2002 +++ phpdoc/en/reference/array/functions/usort.xml Sat Oct 26 02:58:16 2002 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <!-- splitted from ./en/functions/array.xml, last change in rev 1.2 --> <refentry id="function.usort"> <refnamediv> @@ -13,7 +13,7 @@ <methodsynopsis> <type>void</type><methodname>usort</methodname> <methodparam><type>array</type><parameter>array</parameter></methodparam> - <methodparam><type>string</type><parameter>cmp_function</parameter></methodparam> + +<methodparam><type>callback</type><parameter>cmp_function</parameter></methodparam> </methodsynopsis> <para> This function will sort an array by its values using a @@ -116,7 +116,7 @@ ]]> </screen> </para> - ¬e.func-callback; + <para> <example> <title> @@ -165,13 +165,7 @@ d </screen> </para> - <warning> - <para> - The underlying quicksort function in some C libraries (such as - on Solaris systems) may cause PHP to crash if the comparison - function does not return consistent values. - </para> - </warning> + <para> See also <function>uasort</function>, <function>uksort</function>, <function>sort</function>,
-- PHP Documentation Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php