cvs: phpdoc /en/reference/funchand/functions call-user-func-array.xml call-user-func.xml create-function.xml function-exists.xml
get-defined-functions.xml
| From: | Derick Rethans | Date: | Mon, 16 Jun 2003 14:37:37 +0000 |
| Subject: | cvs: phpdoc /en/reference/funchand/functions call-user-func-array.xml call-user-func.xml create-function.xml function-exists.xml get-defined-functions.xml |
||
| Groups: | php.doc | ||
| Request: | Send a blank email to phpdoc+get-969354508@lists.php.net to get a copy of this message | ||
derick Mon Jun 16 10:37:37 2003 EDT
Modified files:
/phpdoc/en/reference/funchand/functions call-user-func-array.xml
call-user-func.xml
create-function.xml
function-exists.xml
get-defined-functions.xml
Log:
- Restructuring
Index: phpdoc/en/reference/funchand/functions/call-user-func-array.xml diff -u phpdoc/en/reference/funchand/functions/call-user-func-array.xml:1.4 phpdoc/en/reference/funchand/functions/call-user-func-array.xml:1.5 --- phpdoc/en/reference/funchand/functions/call-user-func-array.xml:1.4 Sat Oct 26 16:40:42 2002 +++ phpdoc/en/reference/funchand/functions/call-user-func-array.xml Mon Jun 16 10:37:37 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <!-- splitted from ./en/functions/funchand.xml, last change in rev 1.10 --> <refentry id="function.call-user-func-array"> <refnamediv> @@ -20,9 +20,12 @@ <parameter>function</parameter>, with the parameters in <parameter>paramarr</parameter>. For example: + </para> + <para> <informalexample> <programlisting role="php"> <![CDATA[ +<?php function debug($var, $val) echo "***DEBUGGING\nVARIABLE: $var\nVALUE:"; if (is_array($val) || is_object($val) || is_resource($val)) @@ -38,6 +41,7 @@ call_user_func_array ('debug', array("host", $host)); call_user_func_array ('debug', array("c", $c)); call_user_func_array ('debug', array("_POST", $_POST)); +?> ]]> </programlisting> </informalexample> Index: phpdoc/en/reference/funchand/functions/call-user-func.xml diff -u phpdoc/en/reference/funchand/functions/call-user-func.xml:1.4 phpdoc/en/reference/funchand/functions/call-user-func.xml:1.5 --- phpdoc/en/reference/funchand/functions/call-user-func.xml:1.4 Tue Jan 28 16:06:51 2003 +++ phpdoc/en/reference/funchand/functions/call-user-func.xml Mon Jun 16 10:37:37 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <!-- splitted from ./en/functions/funchand.xml, last change in rev 1.1 --> <refentry id="function.call-user-func"> <refnamediv> @@ -20,14 +20,18 @@ Call a user defined function given by the <parameter>function</parameter> parameter. Take the following: + </para> + <para> <informalexample> <programlisting role="php"> <![CDATA[ +<?php function barber ($type) { print "You wanted a $type haircut, no problem"; } call_user_func ('barber', "mushroom"); call_user_func ('barber', "shave"); +?> ]]> </programlisting> </informalexample> @@ -36,6 +40,8 @@ Object methods may also be invoked statically using this function by passing <literal>array($objectname, $methodname)</literal> to the <parameter>function</parameter> parameter. + </para> + <para> <informalexample> <programlisting role="php"> <![CDATA[ Index: phpdoc/en/reference/funchand/functions/create-function.xml diff -u phpdoc/en/reference/funchand/functions/create-function.xml:1.2 phpdoc/en/reference/funchand/functions/create-function.xml:1.3 --- phpdoc/en/reference/funchand/functions/create-function.xml:1.2 Wed Apr 17 02:38:18 2002 +++ phpdoc/en/reference/funchand/functions/create-function.xml Mon Jun 16 10:37:37 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/funchand.xml, last change in rev 1.1 --> <refentry id="function.create-function"> <refnamediv> @@ -27,23 +27,31 @@ <para> You can use this function, to (for example) create a function from information gathered at run time: + </para> + <para> <example> <title> Creating an anonymous function with <function>create_function</function> </title> <programlisting role="php"> <![CDATA[ +<?php $newfunc = create_function('$a,$b','return "ln($a) + ln($b) = ".log($a * $b);'); echo "New anonymous function: $newfunc\n"; echo $newfunc(2,M_E)."\n"; // outputs // New anonymous function: lambda_1 // ln(2) + ln(2.718281828459) = 1.6931471805599 +?> ]]> </programlisting> </example> + </para> + <para> Or, perhaps to have general handler function that can apply a set of operations to a list of parameters: + </para> + <para> <example> <title> Making a general processing function with @@ -51,6 +59,7 @@ </title> <programlisting role="php"> <."\n"; @@ -81,12 +90,13 @@ ); echo "\nUsing the second array of anonymous functions\n"; process("Twas brilling and the slithy toves", "Twas the night", $garr); +?> ]]> </programlisting> - </example> - and when you run the code above, the output will be: - <informalexample> - <programlisting> + <para> + and when you run the code above, the output will be: + </para> + <screen> <![CDATA[ Using the first array of anonymous functions parameters: 2.3445, M_PI @@ -102,53 +112,65 @@ CRCs: -725381282 , 1908338681 similar(a,b) = 11(45.833333333333%) ]]> - </programlisting> - </informalexample> - But perhaps the most common use for of lambda-style (anonymous) functions - is to create callback functions, for example when using - <function>array_walk</function> or <function>usort</function> - <example> - <title>Using anonymous functions as callback functions</title> - <programlisting role="php"> + </screen> + </example> + </para> + <para> + But perhaps the most common use for of lambda-style (anonymous) functions + is to create callback functions, for example when using + <function>array_walk</function> or <function>usort</function> + </para> + <para> + <example> + <title>Using anonymous functions as callback functions</title> + <programlisting role="php"> <![CDATA[ +<?php $av = array("the ","a ","that ","this "); array_walk($av, create_function('&$v,$k','$v = $v."mango";')); print_r($av); // for PHP 3 use var_dump() -// outputs: -// Array -// ( -// [0] => the mango -// [1] => a mango -// [2] => that mango -// [3] => this mango -// ) +/* +outputs: +Array +( + [0] => the mango + [1] => a mango + [2] => that mango + [3] => this mango +) +*/ // an array of strings ordered from shorter to longer $sv = array("small","larger","a big string","it is a string thing"); print_r($sv); -// outputs: -// Array -// ( -// [0] => small -// [1] => larger -// [2] => a big string -// [3] => it is a string thing -// ) +/* +outputs: +Array +( + [0] => small + [1] => larger + [2] => a big string + [3] => it is a string thing +) +*/ // sort it from longer to shorter usort($sv, create_function('$a,$b','return strlen($b) - strlen($a);')); print_r($sv); -// outputs: -// Array -// ( -// [0] => it is a string thing -// [1] => a big string -// [2] => larger -// [3] => small -// ) +/* +outputs: +Array +( + [0] => it is a string thing + [1] => a big string + [2] => larger + [3] => small +) +*/ +?> ]]> - </programlisting> - </example> + </programlisting> + </example> </para> </refsect1> </refentry> Index: phpdoc/en/reference/funchand/functions/function-exists.xml diff -u phpdoc/en/reference/funchand/functions/function-exists.xml:1.2 phpdoc/en/reference/funchand/functions/function-exists.xml:1.3 --- phpdoc/en/reference/funchand/functions/function-exists.xml:1.2 Wed Apr 17 02:38:19 2002 +++ phpdoc/en/reference/funchand/functions/function-exists.xml Mon Jun 16 10:37:37 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/funchand.xml, last change in rev 1.1 --> <refentry id="function.function-exists"> <refnamediv> @@ -17,17 +17,23 @@ <para> Checks the list of defined functions, both built-in (internal) and user-defined, for <parameter>function_name</parameter>. &return.success; + </para> + <para> <informalexample> <programlisting role="php"> <![CDATA[ +<?php if (function_exists('imap_open')) { - echo "IMAP functions are available.<br>\n"; + echo "IMAP functions are available.<br />\n"; } else { - echo "IMAP functions are not available.<br>\n"; + echo "IMAP functions are not available.<br />\n"; } +?> ]]> </programlisting> </informalexample> + </para> + <para> Note that a function name may exist even if the function itself is unusable due to configuration or compiling options (with the <link linkend="ref.image">image</link> functions being an example). Index: phpdoc/en/reference/funchand/functions/get-defined-functions.xml diff -u phpdoc/en/reference/funchand/functions/get-defined-functions.xml:1.2 phpdoc/en/reference/funchand/functions/get-defined-functions.xml:1.3 --- phpdoc/en/reference/funchand/functions/get-defined-functions.xml:1.2 Wed Apr 17 02:38:19 2002 +++ phpdoc/en/reference/funchand/functions/get-defined-functions.xml Mon Jun 16 10:37:37 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/funchand.xml, last change in rev 1.6 --> <refentry id="function.get-defined-functions"> <refnamediv> @@ -20,9 +20,12 @@ internal functions will be accessible via <varname>$arr["internal"]</varname>, and the user defined ones using <varname>$arr["user"]</varname> (see example below). + </para> + <para> <informalexample> <programlisting role="php"> <![CDATA[ +<?php function myrow($id, $data) { return "<tr><th>$id</th><td>$data</td></tr>\n"; } @@ -30,14 +33,13 @@ $arr = get_defined_functions(); print_r($arr); +?> ]]> - </programlisting> - </informalexample> - </para> - <para> - Will output something along the lines of: - <informalexample> - <programlisting> + </programlisting> + <para> + Will output something along the lines of: + </para> + <screen> <![CDATA[ Array ( @@ -62,7 +64,7 @@ ) ]]> - </programlisting> + </screen> </informalexample> </para> <para>
Index: phpdoc/en/reference/funchand/functions/call-user-func-array.xml diff -u phpdoc/en/reference/funchand/functions/call-user-func-array.xml:1.4 phpdoc/en/reference/funchand/functions/call-user-func-array.xml:1.5 --- phpdoc/en/reference/funchand/functions/call-user-func-array.xml:1.4 Sat Oct 26 16:40:42 2002 +++ phpdoc/en/reference/funchand/functions/call-user-func-array.xml Mon Jun 16 10:37:37 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <!-- splitted from ./en/functions/funchand.xml, last change in rev 1.10 --> <refentry id="function.call-user-func-array"> <refnamediv> @@ -20,9 +20,12 @@ <parameter>function</parameter>, with the parameters in <parameter>paramarr</parameter>. For example: + </para> + <para> <informalexample> <programlisting role="php"> <![CDATA[ +<?php function debug($var, $val) echo "***DEBUGGING\nVARIABLE: $var\nVALUE:"; if (is_array($val) || is_object($val) || is_resource($val)) @@ -38,6 +41,7 @@ call_user_func_array ('debug', array("host", $host)); call_user_func_array ('debug', array("c", $c)); call_user_func_array ('debug', array("_POST", $_POST)); +?> ]]> </programlisting> </informalexample> Index: phpdoc/en/reference/funchand/functions/call-user-func.xml diff -u phpdoc/en/reference/funchand/functions/call-user-func.xml:1.4 phpdoc/en/reference/funchand/functions/call-user-func.xml:1.5 --- phpdoc/en/reference/funchand/functions/call-user-func.xml:1.4 Tue Jan 28 16:06:51 2003 +++ phpdoc/en/reference/funchand/functions/call-user-func.xml Mon Jun 16 10:37:37 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> +<!-- $Revision: 1.5 $ --> <!-- splitted from ./en/functions/funchand.xml, last change in rev 1.1 --> <refentry id="function.call-user-func"> <refnamediv> @@ -20,14 +20,18 @@ Call a user defined function given by the <parameter>function</parameter> parameter. Take the following: + </para> + <para> <informalexample> <programlisting role="php"> <![CDATA[ +<?php function barber ($type) { print "You wanted a $type haircut, no problem"; } call_user_func ('barber', "mushroom"); call_user_func ('barber', "shave"); +?> ]]> </programlisting> </informalexample> @@ -36,6 +40,8 @@ Object methods may also be invoked statically using this function by passing <literal>array($objectname, $methodname)</literal> to the <parameter>function</parameter> parameter. + </para> + <para> <informalexample> <programlisting role="php"> <![CDATA[ Index: phpdoc/en/reference/funchand/functions/create-function.xml diff -u phpdoc/en/reference/funchand/functions/create-function.xml:1.2 phpdoc/en/reference/funchand/functions/create-function.xml:1.3 --- phpdoc/en/reference/funchand/functions/create-function.xml:1.2 Wed Apr 17 02:38:18 2002 +++ phpdoc/en/reference/funchand/functions/create-function.xml Mon Jun 16 10:37:37 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/funchand.xml, last change in rev 1.1 --> <refentry id="function.create-function"> <refnamediv> @@ -27,23 +27,31 @@ <para> You can use this function, to (for example) create a function from information gathered at run time: + </para> + <para> <example> <title> Creating an anonymous function with <function>create_function</function> </title> <programlisting role="php"> <![CDATA[ +<?php $newfunc = create_function('$a,$b','return "ln($a) + ln($b) = ".log($a * $b);'); echo "New anonymous function: $newfunc\n"; echo $newfunc(2,M_E)."\n"; // outputs // New anonymous function: lambda_1 // ln(2) + ln(2.718281828459) = 1.6931471805599 +?> ]]> </programlisting> </example> + </para> + <para> Or, perhaps to have general handler function that can apply a set of operations to a list of parameters: + </para> + <para> <example> <title> Making a general processing function with @@ -51,6 +59,7 @@ </title> <programlisting role="php"> <."\n"; @@ -81,12 +90,13 @@ ); echo "\nUsing the second array of anonymous functions\n"; process("Twas brilling and the slithy toves", "Twas the night", $garr); +?> ]]> </programlisting> - </example> - and when you run the code above, the output will be: - <informalexample> - <programlisting> + <para> + and when you run the code above, the output will be: + </para> + <screen> <![CDATA[ Using the first array of anonymous functions parameters: 2.3445, M_PI @@ -102,53 +112,65 @@ CRCs: -725381282 , 1908338681 similar(a,b) = 11(45.833333333333%) ]]> - </programlisting> - </informalexample> - But perhaps the most common use for of lambda-style (anonymous) functions - is to create callback functions, for example when using - <function>array_walk</function> or <function>usort</function> - <example> - <title>Using anonymous functions as callback functions</title> - <programlisting role="php"> + </screen> + </example> + </para> + <para> + But perhaps the most common use for of lambda-style (anonymous) functions + is to create callback functions, for example when using + <function>array_walk</function> or <function>usort</function> + </para> + <para> + <example> + <title>Using anonymous functions as callback functions</title> + <programlisting role="php"> <![CDATA[ +<?php $av = array("the ","a ","that ","this "); array_walk($av, create_function('&$v,$k','$v = $v."mango";')); print_r($av); // for PHP 3 use var_dump() -// outputs: -// Array -// ( -// [0] => the mango -// [1] => a mango -// [2] => that mango -// [3] => this mango -// ) +/* +outputs: +Array +( + [0] => the mango + [1] => a mango + [2] => that mango + [3] => this mango +) +*/ // an array of strings ordered from shorter to longer $sv = array("small","larger","a big string","it is a string thing"); print_r($sv); -// outputs: -// Array -// ( -// [0] => small -// [1] => larger -// [2] => a big string -// [3] => it is a string thing -// ) +/* +outputs: +Array +( + [0] => small + [1] => larger + [2] => a big string + [3] => it is a string thing +) +*/ // sort it from longer to shorter usort($sv, create_function('$a,$b','return strlen($b) - strlen($a);')); print_r($sv); -// outputs: -// Array -// ( -// [0] => it is a string thing -// [1] => a big string -// [2] => larger -// [3] => small -// ) +/* +outputs: +Array +( + [0] => it is a string thing + [1] => a big string + [2] => larger + [3] => small +) +*/ +?> ]]> - </programlisting> - </example> + </programlisting> + </example> </para> </refsect1> </refentry> Index: phpdoc/en/reference/funchand/functions/function-exists.xml diff -u phpdoc/en/reference/funchand/functions/function-exists.xml:1.2 phpdoc/en/reference/funchand/functions/function-exists.xml:1.3 --- phpdoc/en/reference/funchand/functions/function-exists.xml:1.2 Wed Apr 17 02:38:19 2002 +++ phpdoc/en/reference/funchand/functions/function-exists.xml Mon Jun 16 10:37:37 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/funchand.xml, last change in rev 1.1 --> <refentry id="function.function-exists"> <refnamediv> @@ -17,17 +17,23 @@ <para> Checks the list of defined functions, both built-in (internal) and user-defined, for <parameter>function_name</parameter>. &return.success; + </para> + <para> <informalexample> <programlisting role="php"> <![CDATA[ +<?php if (function_exists('imap_open')) { - echo "IMAP functions are available.<br>\n"; + echo "IMAP functions are available.<br />\n"; } else { - echo "IMAP functions are not available.<br>\n"; + echo "IMAP functions are not available.<br />\n"; } +?> ]]> </programlisting> </informalexample> + </para> + <para> Note that a function name may exist even if the function itself is unusable due to configuration or compiling options (with the <link linkend="ref.image">image</link> functions being an example). Index: phpdoc/en/reference/funchand/functions/get-defined-functions.xml diff -u phpdoc/en/reference/funchand/functions/get-defined-functions.xml:1.2 phpdoc/en/reference/funchand/functions/get-defined-functions.xml:1.3 --- phpdoc/en/reference/funchand/functions/get-defined-functions.xml:1.2 Wed Apr 17 02:38:19 2002 +++ phpdoc/en/reference/funchand/functions/get-defined-functions.xml Mon Jun 16 10:37:37 2003 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- splitted from ./en/functions/funchand.xml, last change in rev 1.6 --> <refentry id="function.get-defined-functions"> <refnamediv> @@ -20,9 +20,12 @@ internal functions will be accessible via <varname>$arr["internal"]</varname>, and the user defined ones using <varname>$arr["user"]</varname> (see example below). + </para> + <para> <informalexample> <programlisting role="php"> <![CDATA[ +<?php function myrow($id, $data) { return "<tr><th>$id</th><td>$data</td></tr>\n"; } @@ -30,14 +33,13 @@ $arr = get_defined_functions(); print_r($arr); +?> ]]> - </programlisting> - </informalexample> - </para> - <para> - Will output something along the lines of: - <informalexample> - <programlisting> + </programlisting> + <para> + Will output something along the lines of: + </para> + <screen> <![CDATA[ Array ( @@ -62,7 +64,7 @@ ) ]]> - </programlisting> + </screen> </informalexample> </para> <para>