cvs: phpdoc-fr /reference/funchand reference.xml /reference/funchand/functions call-user-func-array.xml call-user-func.xml create-function.xml
func-get-arg.xml func-get-args.xml func-num-args.xml function-exists.xml get-defined-functions.xml register-shutdown-function.xml
register-tick-function.xml unregister-tick-function.xml
| From: | Damien Seguy | Date: | Mon, 22 Sep 2003 13:25:07 +0000 |
| Subject: | cvs: phpdoc-fr /reference/funchand reference.xml /reference/funchand/functions call-user-func-array.xml call-user-func.xml create-function.xml func-get-arg.xml func-get-args.xml func-num-args.xml function-exists.xml get-defined-functions.xml register-shutdown-function.xml register-tick-function.xml unregister-tick-function.xml |
||
| Groups: | php.doc.fr | ||
| Request: | Send a blank email to doc-fr+get-780@lists.php.net to get a copy of this message | ||
dams Mon Sep 22 09:25:07 2003 EDT
Modified files:
/phpdoc-fr/reference/funchand reference.xml
/phpdoc-fr/reference/funchand/functions call-user-func-array.xml
call-user-func.xml
create-function.xml
func-get-arg.xml
func-get-args.xml
func-num-args.xml
function-exists.xml
get-defined-functions.xml
register-shutdown-function.xml
register-tick-function.xml
unregister-tick-function.xml
Log:
keep up with en
Index: phpdoc-fr/reference/funchand/reference.xml diff -u phpdoc-fr/reference/funchand/reference.xml:1.2 phpdoc-fr/reference/funchand/reference.xml:1.3 --- phpdoc-fr/reference/funchand/reference.xml:1.2 Mon Apr 15 20:53:34 2002 +++ phpdoc-fr/reference/funchand/reference.xml Mon Sep 22 09:25:06 2003 @@ -1,14 +1,39 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <reference id="ref.funchand"> <title>Fonctions</title> <titleabbrev>Fonctions</titleabbrev> - <partintro> - <para> + + <partintro> + <section id="funchand.intro"> + &reftitle.intro; + <para> Ces fonctions effectuent les manipulations liées à la gestion des fonctions. - </para> - </partintro> + </para> + </section> + + <section id="funchand.requirements"> + &reftitle.required; + &no.requirement; + </section> + + <section id="funchand.installation"> + &reftitle.install; + &no.install; + </section> + + <section id="funchand.configuration"> + &reftitle.runtime; + &no.config; + </section> + + <section id="funchand.constants"> + &reftitle.constants; + &no.constants; + </section> + + </partintro> &reference.funchand.functions; Index: phpdoc-fr/reference/funchand/functions/call-user-func-array.xml diff -u phpdoc-fr/reference/funchand/functions/call-user-func-array.xml:1.1 phpdoc-fr/reference/funchand/functions/call-user-func-array.xml:1.2 --- phpdoc-fr/reference/funchand/functions/call-user-func-array.xml:1.1 Sun Apr 14 20:28:46 2002 +++ phpdoc-fr/reference/funchand/functions/call-user-func-array.xml Mon Sep 22 09:25:06 2003 @@ -10,19 +10,19 @@ </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>mixed</type><methodname>call_user_func_array</methodname> - <methodparam><type>string</type><parameter>function_name</parameter></methodparam> - <methodparam choice="opt"><type>array</type><parameter>paramarr</parameter></methodparam> - </methodsynopsis> + <methodsynopsis> + <type>mixed</type><methodname>call_user_func_array</methodname> + <methodparam><type>callback</type><parameter>function</parameter></methodparam> + <methodparam choice="opt"><type>array</type><parameter>paramarr</parameter></methodparam> + </methodsynopsis> <para> <function>call_user_func_array</function> appelle la fonction utilisateur <parameter>function_name</parameter> avec les paramètres <parameter>paramarr</parameter>, rassemblés dans un tableau. - Par exemple: - <informalexample> + <example> + <title>Exemple avec <function>call_user_func_array</function></title> <programlisting role="php"> -<?php +<![CDATA[ function debug($var, $val) echo "***DEBUGGING\nVARIABLE: $var\nVALUE:"; if (is_array($val) || is_object($val) || is_resource($val)) @@ -31,14 +31,16 @@ echo "\n$val\n"; echo "***\n"; } + $c = mysql_connect(); -$host = $HTTP_SERVER_VARS["SERVER_NAME"]; +$host = $_SERVER["SERVER_NAME"]; + call_user_func_array ('debug', array("host", $host)); call_user_func_array ('debug', array("c", $c)); -call_user_func_array ('debug', array("HTTP_POST_VARS", $HTTP_POST_VARS)); -?> +call_user_func_array ('debug', array("_POST", $_POST)); +]]> </programlisting> - </informalexample> + </example> </para> <para> Voir aussi @@ -46,12 +48,6 @@ <function>call_user_method</function> et <function>call_user_method_array</function>. </para> - <note> - <para> - <function>call_user_func_array</function> a été ajouté - en version PHP 4.05. - </para> - </note> </refsect1> </refentry> Index: phpdoc-fr/reference/funchand/functions/call-user-func.xml diff -u phpdoc-fr/reference/funchand/functions/call-user-func.xml:1.1 phpdoc-fr/reference/funchand/functions/call-user-func.xml:1.2 --- phpdoc-fr/reference/funchand/functions/call-user-func.xml:1.1 Sun Apr 14 20:28:48 2002 +++ phpdoc-fr/reference/funchand/functions/call-user-func.xml Mon Sep 22 09:25:06 2003 @@ -10,30 +10,56 @@ </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>mixed</type><methodname>call_user_func</methodname> - <methodparam><type>string</type><parameter>function_name</parameter></methodparam> - <methodparam choice="opt"><type>mixed</type><parameter>parameter</parameter></methodparam> - <methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam> - </methodsynopsis> + <methodsynopsis> + <type>mixed</type><methodname>call_user_func</methodname> + <methodparam><type>callback</type><parameter>function</parameter></methodparam> + <methodparam choice="opt"><type>mixed</type><parameter>parameter</parameter></methodparam> + <methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam> + </methodsynopsis> <para> <function>call_user_func</function> appelle la fonction utilisateur <parameter>function_name</parameter>, et lui passe les paramètres <parameter>parameter</parameter>. - Par exemple : - <informalexample> + <example> + <title>Exemple avec <function>call_user_func</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function barbier ($type) { print "Vous vouliez une coupe $type, pas de problème"; } - call_user_func('barbier', "iroquois"); + + call_user_func('barbier', "à la one again"); call_user_func('barbier', "militaire"); call_user_func('barbier', "au bol"); -?> +?> +]]> </programlisting> - </informalexample> + </example> </para> + <para> + Les méthodes d'objets peuvent être appelées statiquement + en passant <literal>array($objectname, $methodname)</literal> au + paramètre <parameter>function</parameter>. + <example> + <title>Exemple avec <function>call_user_func</function> et une méthode de classe</title> + <programlisting role="php"> +<![CDATA[ +<?php +class maclasse { + function dit_bonjour() { + print "Bonjour!\n"; + } +} + +$classname = "maclasse"; + +call_user_func(array($classname,'dit_bonjour')); +?> +]]> + </programlisting> + </example> + </para> <para> Voir aussi <function>call_user_func_array</function>, Index: phpdoc-fr/reference/funchand/functions/create-function.xml diff -u phpdoc-fr/reference/funchand/functions/create-function.xml:1.2 phpdoc-fr/reference/funchand/functions/create-function.xml:1.3 --- phpdoc-fr/reference/funchand/functions/create-function.xml:1.2 Thu Aug 14 10:48:53 2003 +++ phpdoc-fr/reference/funchand/functions/create-function.xml Mon Sep 22 09:25:06 2003 @@ -34,14 +34,16 @@ Création d'une fonction anonyme avec <function>create_function</function> </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $newfunc = create_function('$a,$b','return "ln($a) + ln($b) = ".log($a * $b);'); echo "Nouvelle fonction anonyme : $newfunc\n"; echo $newfunc(2,M_E)."\n"; // affichera : // Nouvelle fonction anonyme : lambda_1 // ln(2) + ln(2.718281828459) = 1.6931471805599 -?> +?> +]]> </programlisting> </example> Ou, pour pouvoir appliquer une fonction générique @@ -52,15 +54,17 @@ <function>create_function</function> </title> <programlisting role="php"> -<?php +<."\n"; } -// création d'une série de fonction mathématiques -$f1 = 'if ($a>=0) {return "b*a^2 = ".$b*sqrt($a);} else {return FALSE;}'; + +// Création d'une série de fonction mathématiques +$f1 = 'if ($a>=0) {return "b*a^2 = ".$b*sqrt($a);} else {return FALSE;}'; $f2 = "return \"min(b^2+a, a^2,b) = \".min(\$a*\$a+\$b,\$b*\$b+\$a);"; -$f3 = 'if ($a> 0 && $b != 0) {return "ln(a)/b = ".log($a)/$b;} else {return FALSE;}'; +$f3 = 'if ($a> 0 && $b != 0) {return "ln(a)/b = ".log($a)/$b;} else {return FALSE;}'; $farr = array( create_function('$x,$y', 'return "un peu de trigo : ".(sin($x) + $x*cos($y));'), create_function('$x,$y', 'return "une hypoténuse: ".sqrt($x*$x + $y*$y);'), @@ -68,55 +72,62 @@ create_function('$a,$b', $f2), create_function('$a,$b', $f3) ); + echo "\nUtilisation de la première liste de fonctions anonymes\n"; echo "paramétres: 2.3445, M_PI\n"; process(2.3445, M_PI, $farr); + // Maintenant une liste de fonction sur chaîne de caractères $garr = array( create_function('$b,$a','if (strncmp($a,$b,3) == 0) return "** \"$a\" '. 'et \"$b\"\n** Ces chaînes de ressemblent!! (regarde les trois premiers caractères)";'), create_function('$a,$b','; return "CRCs: ".crc32($a)." , ".crc32(b);'), - create_function('$a,$b','; return "similarité(a,b) = ".similar_text($a,$b,&$p)."($p%)";') + create_function('$a,$b','; return "similarité(a,b) = ".similar_text($a,$b,&$p)."($p%)";') ); echo "\nUtilisation de la secondes liste de fonctions anonymes\n"; process("Twas brilling and the slithy toves", "Twas the night", $garr); -?> +?> +]]> </programlisting> - </example> - Et lorsque vous utilisez le code ci-dessus, l'affichage va être - <informalexample> + <para> + Et lorsque vous utilisez le code ci-dessus, l'affichage sera + </para> <programlisting> +<![CDATA[ Utilisation de la première liste de fonctions anonymes paramétres: 2.3445, M_PI -Un peu de trigo: -1.6291725057799 -Une hypoténuse: 3.9199852871011 +un peu de trigo : -1.6291725057799 +une hypoténuse: 3.9199852871011 b*a^2 = 4.8103313314525 min(b^2+a, a^2,b) = 8.6382729035898 -ln(a/b) = 0.27122299212594 -Utilisation de la seconde liste de fonctions anonymes +ln(a)/b = 0.27122299212594 + +Utilisation de la secondes liste de fonctions anonymes ** "Twas the night" et "Twas brilling and the slithy toves" ** Ces chaînes de ressemblent!! (regarde les trois premiers caractères) CRCs: -725381282 , 1908338681 similarité(a,b) = 11(45.833333333333%) +]]> </programlisting> - </informalexample> + </example> Mais l'utilisation la plus courante des fonctions lambda est la fonction de callback, par exemple lors de l'utilisation de <function>array_walk</function> ou <function>usort</function> <example> <title>Utilisation de fonctions anonymes comme fonction de callback</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $av = array("la ","une ","cette ","une certaine "); -array_walk($av, create_function('&$v,$k','$v = $v."maison";')); -print_r($av); // En PHP 3 utilisez <function>var_dump</function> +array_walk($av, create_function('&$v,$k','$v = $v."maison";')); +print_r($av); // En PHP 3 utilisez var_dump() // affiche: // Array // ( -// [0] => la maison -// [1] => une maison -// [2] => cette maison -// [3] => une certaine maison +// [0] => la maison +// [1] => une maison +// [2] => cette maison +// [3] => une certaine maison // ) // un tableau de chaîne classé par taille $sv = array("petite","moyenne","tres longue","vraiment tres longue"); @@ -124,10 +135,10 @@ // affiche: // Array // ( -// [0] => petite -// [1] => moyenne -// [2] => tres longue -// [3] => vraiment tres longue +// [0] => petite +// [1] => moyenne +// [2] => tres longue +// [3] => vraiment tres longue // ) // Tri par ordre de taille décroissant usort($sv, create_function('$a,$b','return strlen($b) - strlen($a);')); @@ -135,12 +146,13 @@ // outputs: // Array // ( -// [0] => vraiment tres longue -// [1] => tres longue -// [2] => moyenne -// [3] => petite +// [0] => vraiment tres longue +// [1] => tres longue +// [2] => moyenne +// [3] => petite // ) -?> +?> +]]> </programlisting> </example> </para> Index: phpdoc-fr/reference/funchand/functions/func-get-arg.xml diff -u phpdoc-fr/reference/funchand/functions/func-get-arg.xml:1.1 phpdoc-fr/reference/funchand/functions/func-get-arg.xml:1.2 --- phpdoc-fr/reference/funchand/functions/func-get-arg.xml:1.1 Sun Apr 14 20:28:48 2002 +++ phpdoc-fr/reference/funchand/functions/func-get-arg.xml Mon Sep 22 09:25:06 2003 @@ -25,23 +25,26 @@ <simpara> Si <parameter>arg_num</parameter> est plus grand que le nombre d'arguments passés, une alerte est générée - et la fonction retourne <literal>FALSE</literal>. + et la fonction retourne &false;. </simpara> <para> - <informalexample> + <example> + <title>Exemple avec <function>func_get_arg</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function foo() { $numargs = func_num_args(); - echo "Nombre d'arguments: $numargs<br>\n"; - if ($numargs >= 2) { - echo "Le second argument est: " . func_get_arg (1) . "<br>\n"; + echo "Nombre d'arguments: $numargs<BR>\n"; + if ($numargs >= 2) { + echo "Le second argument est: " . func_get_arg (1) . "<BR>\n"; } } foo(1, 2, 3); -?> +?> +]]> </programlisting> - </informalexample> + </example> </para> <simpara> <function>func_get_arg</function> peut être utilisé Index: phpdoc-fr/reference/funchand/functions/func-get-args.xml diff -u phpdoc-fr/reference/funchand/functions/func-get-args.xml:1.1 phpdoc-fr/reference/funchand/functions/func-get-args.xml:1.2 --- phpdoc-fr/reference/funchand/functions/func-get-args.xml:1.1 Sun Apr 14 20:28:48 2002 +++ phpdoc-fr/reference/funchand/functions/func-get-args.xml Mon Sep 22 09:25:06 2003 @@ -12,7 +12,7 @@ <title>Description</title> <methodsynopsis> <type>array</type><methodname>func_get_args</methodname> - <methodparam><type>void</type><parameter/></methodparam> + <void/> </methodsynopsis> <simpara> <function>func_get_args</function> retourne un tableau dont @@ -22,24 +22,27 @@ alerte si elle est appelée hors d'une fonction. </simpara> <para> - <informalexample> + <example> + <title>Exemple avec <function>func_get_args</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function foo() { $numargs = func_num_args(); - echo "Nombre d'arguments: $numargs<br>\n"; - if ($numargs >= 2) { - echo "Le second argument est: " . func_get_arg (1) . "<br>\n"; + echo "Nombre d'arguments: $numargs<BR>\n"; + if ($numargs >= 2) { + echo "Le second argument est : " . func_get_arg (1) . "<BR>\n"; } $arg_list = func_get_args(); - for ($i = 0; $i < $numargs; $i++) { - echo "L'argument $i est: " . $arg_list[$i] . "<br>\n"; + for ($i = 0; $i < $numargs; $i++) { + echo "L'argument $i est : " . $arg_list[$i] . "<BR>\n"; } } foo(1, 2, 3); -?> +?> +]]> </programlisting> - </informalexample> + </example> </para> <simpara> <function>func_get_arg</function> peut être utilisé Index: phpdoc-fr/reference/funchand/functions/func-num-args.xml diff -u phpdoc-fr/reference/funchand/functions/func-num-args.xml:1.1 phpdoc-fr/reference/funchand/functions/func-num-args.xml:1.2 --- phpdoc-fr/reference/funchand/functions/func-num-args.xml:1.1 Sun Apr 14 20:28:49 2002 +++ phpdoc-fr/reference/funchand/functions/func-num-args.xml Mon Sep 22 09:25:06 2003 @@ -12,7 +12,7 @@ <title>Description</title> <methodsynopsis> <type>int</type><methodname>func_num_args</methodname> - <methodparam><type>void</type><parameter/></methodparam> + <void/> </methodsynopsis> <simpara> <function>func_num_args</function> retourne le nombre d'arguments @@ -22,17 +22,20 @@ hors d'une fonction. </simpara> <para> - <informalexample> + <example> + <title>Exemple avec <function>func_num_args</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function foo() { $numargs = func_num_args(); echo "Nombre d'arguments: $numargs\n"; } foo (1, 2, 3); // affiche 'Nombre d'arguments: 3' -?> +?> +]]> </programlisting> - </informalexample> + </example> </para> <simpara> <function>func_get_arg</function> peut être utilisé Index: phpdoc-fr/reference/funchand/functions/function-exists.xml diff -u phpdoc-fr/reference/funchand/functions/function-exists.xml:1.2 phpdoc-fr/reference/funchand/functions/function-exists.xml:1.3 --- phpdoc-fr/reference/funchand/functions/function-exists.xml:1.2 Tue Aug 13 22:19:32 2002 +++ phpdoc-fr/reference/funchand/functions/function-exists.xml Mon Sep 22 09:25:06 2003 @@ -5,37 +5,40 @@ <refnamediv> <refname>function_exists</refname> <refpurpose> - Indique si une fonction est définie. + Indique si une fonction est définie </refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> - <type>boolean</type><methodname>function_exists</methodname> + <type>bool</type><methodname>function_exists</methodname> <methodparam><type>string</type><parameter>function_name</parameter></methodparam> </methodsynopsis> <para> <function>function_exists</function> vérifie la liste des - fonctions définies par l'utilisateur, et retourne - &true; si <parameter>function_name</parameter> - y est trouvé, &false;sinon. - <informalexample> + fonctions définies par l'utilisateur. + &return.success; + <example> + <title>Exemple avec <function>function_exists</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (function_exists('imap_open')) { - echo "Les fonctions IMAP sont disponibles.<br>\n"; + echo "Les fonctions IMAP sont disponibles.<BR>\n"; } else { - echo "Les fonctions IMAP ne sont pas disponibles.<br>\n"; + echo "Les fonctions IMAP ne sont pas disponibles.<BR>\n"; } -?> +?> +]]> </programlisting> - </informalexample> + </example> Notez qu'une fonction peut exister, même si elle est indisponible, à cause de la configuration ou des options de compilation. </para> <para> Voir aussi - <function>method_exists</function>. + <function>method_exists</function> et + <function>get_defined_functions</function>. </para> </refsect1> </refentry> Index: phpdoc-fr/reference/funchand/functions/get-defined-functions.xml diff -u phpdoc-fr/reference/funchand/functions/get-defined-functions.xml:1.1 phpdoc-fr/reference/funchand/functions/get-defined-functions.xml:1.2 --- phpdoc-fr/reference/funchand/functions/get-defined-functions.xml:1.1 Sun Apr 14 20:28:49 2002 +++ phpdoc-fr/reference/funchand/functions/get-defined-functions.xml Mon Sep 22 09:25:06 2003 @@ -12,7 +12,7 @@ <title>Description</title> <methodsynopsis> <type>array</type><methodname>get_defined_functions</methodname> - <methodparam><type>void</type><parameter/></methodparam> + <void/> </methodsynopsis> <para> <function>get_defined_functions</function> retourne un tableau multi- @@ -21,48 +21,52 @@ définie par l'utilisateur. Les noms des fonctions internes sont accessibles via <varname>$arr["internal"]</varname>, et les fonctions utilisateur sont accessibles via <varname>$arr["user"]</varname>. - <informalexample> + <example> + <title>Exemple avec <function>get_defined_functions</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function maligne($id, $data) { - return "<tr><th>$id</th><td>$data</td></tr>\n"; + return "<tr><th>$id</th><td>$data</td></tr>\n"; } $arr = get_defined_functions(); print_r($arr); -?> +?> +]]> </programlisting> - </informalexample> - </para> <para> Ce script va afficher : - <informalexample> + </para> <programlisting> +<![CDATA[ Array ( - [internal] => Array + [internal] => Array ( - [0] => zend_version - [1] => func_num_args - [2] => func_get_arg - [3] => func_get_args - [4] => strlen - [5] => strcmp - [6] => strncmp + [0] => zend_version + [1] => func_num_args + [2] => func_get_arg + [3] => func_get_args + [4] => strlen + [5] => strcmp + [6] => strncmp ... - [750] => bcscale - [751] => bccomp + [750] => bcscale + [751] => bccomp ) - [user] => Array + [user] => Array ( - [0] => maligne + [0] => maligne ) ) +]]> </programlisting> - </informalexample> + </example> </para> <para> Voir aussi - <function>get_defined_vars</function>. + <function>get_defined_vars</function> et + <function>get_defined_constants</function>. </para> </refsect1> </refentry> Index: phpdoc-fr/reference/funchand/functions/register-shutdown-function.xml diff -u phpdoc-fr/reference/funchand/functions/register-shutdown-function.xml:1.1 phpdoc-fr/reference/funchand/functions/register-shutdown-function.xml:1.2 --- phpdoc-fr/reference/funchand/functions/register-shutdown-function.xml:1.1 Sun Apr 14 20:28:49 2002 +++ phpdoc-fr/reference/funchand/functions/register-shutdown-function.xml Mon Sep 22 09:25:06 2003 @@ -10,23 +10,47 @@ </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>int</type><methodname>register_shutdown_function</methodname> - <methodparam><type>string</type><parameter>func</parameter></methodparam> - </methodsynopsis> + <methodsynopsis> + <type>void</type><methodname>register_shutdown_function</methodname> + <methodparam><type>callback</type><parameter>function</parameter></methodparam> + </methodsynopsis> <simpara> <function>register_shutdown_function</function> enregistre la fonction <parameter>func</parameter> pour exécution à l'extinction du script. </simpara> - <para> - Erreur courante : - </para> - <simpara> - Etant donné qu'aucun affichage n'est possible depuis la fonction - <parameter>func</parameter>, vous ne pouvez pas y mettre d'informations - de débuggage par <function>print</function> ou <function>echo</function>! - </simpara> + <para> + Plusieurs appels à <function>register_shutdown_function</function> sont + possibles dans le même script, et les fonctions seront appelées dans le + même ordre que celui dans elles sont enregistrées. SI vous appelez + <function>exit</function> durant l'une des fonctions d'extinction, + le processus sera définitivement arrété, sans que les autres fonctions + soient appelées. + </para> + <para> + Les fonctions d'extinction sont appelées après la fin de la requête + (notamment les buffers ont été vidés), ce qui fait qu'il est impossible + d'afficher du texte depuis cette fonction, avec <function>echo</function> ou + <function>print</function>, ou encore de lire le contenu des buffers + avec <function>ob_get_contents</function>. + </para> + <note> + <para> + Typiquement, les fonctions non définies causent des + erreurs fatales en &php;, mais lorsque la fonction + <parameter>function</parameter> est appelée avec + <function>register_shutdown_function</function> en étant non définie, + une erreur de type <constant>E_WARNING</constant> est générée. De plus, + pour des raisons internes à &php; cette erreur va être indiquée + comme <literal>Unknown at line #0</literal>. + </para> + </note> + <para> + Voir aussi + <link linkend="ini.auto-append-file">auto_append_file</link>, + <function>exit</function>, et la section sur la + <link linkend="features.connection-handling">gestion des connexions</link>. + </para> </refsect1> </refentry> Index: phpdoc-fr/reference/funchand/functions/register-tick-function.xml diff -u phpdoc-fr/reference/funchand/functions/register-tick-function.xml:1.1 phpdoc-fr/reference/funchand/functions/register-tick-function.xml:1.2 --- phpdoc-fr/reference/funchand/functions/register-tick-function.xml:1.1 Sun Apr 14 20:28:49 2002 +++ phpdoc-fr/reference/funchand/functions/register-tick-function.xml Mon Sep 22 09:25:06 2003 @@ -10,16 +10,39 @@ </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>void</type><methodname>register_tick_function</methodname> - <methodparam><type>string</type><parameter>func</parameter></methodparam> - <methodparam choice="opt"><type>mixed</type><parameter>arg</parameter></methodparam> - </methodsynopsis> + <methodsynopsis> + <type>void</type><methodname>register_tick_function</methodname> + <methodparam><type>callback</type><parameter>function</parameter></methodparam> + <methodparam choice="opt"><type>mixed</type><parameter>arg</parameter></methodparam> + </methodsynopsis> <simpara> <function>register_tick_function</function> enregistre la fonction - <parameter>func</parameter> pour être exécutée à chaque fois qu'un + <parameter>func</parameter> pour être exécutée + à chaque fois qu'un <link linkend="control-structures.declare">tick</link> est appelé. </simpara> + <para> + <example> + <title>Exemple avec <function>register_tick_function</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +// Utilisation d'une fonction de callback +register_tick_function('ma_function', TRUE); + +// Utilisation d'une méthode d'objet +$objet = new ma_classe(); +register_tick_function(array(&$objet, 'ma_methode'), TRUE); +?> +]]> + </programlisting> + </example> + </para> + <para> + Voir aussi + <function>declare</function> et + <function>unregister_tick_function</function>. + </para> </refsect1> </refentry> Index: phpdoc-fr/reference/funchand/functions/unregister-tick-function.xml diff -u phpdoc-fr/reference/funchand/functions/unregister-tick-function.xml:1.1 phpdoc-fr/reference/funchand/functions/unregister-tick-function.xml:1.2 --- phpdoc-fr/reference/funchand/functions/unregister-tick-function.xml:1.1 Sun Apr 14 20:28:49 2002 +++ phpdoc-fr/reference/funchand/functions/unregister-tick-function.xml Mon Sep 22 09:25:06 2003 @@ -10,11 +10,10 @@ </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>void</type><methodname>unregister_tick_function</methodname> - <methodparam><type>string</type><parameter>func</parameter></methodparam> - <methodparam choice="opt"><type>mixed</type><parameter>arg</parameter></methodparam> - </methodsynopsis> + <methodsynopsis> + <type>void</type><methodname>unregister_tick_function</methodname> + <methodparam><type>string</type><parameter>function_name</parameter></methodparam> + </methodsynopsis> <simpara> <function>unregister_tick_function</function> annule l'exécution automatique de <parameter>func</parameter> à chaque
Index: phpdoc-fr/reference/funchand/reference.xml diff -u phpdoc-fr/reference/funchand/reference.xml:1.2 phpdoc-fr/reference/funchand/reference.xml:1.3 --- phpdoc-fr/reference/funchand/reference.xml:1.2 Mon Apr 15 20:53:34 2002 +++ phpdoc-fr/reference/funchand/reference.xml Mon Sep 22 09:25:06 2003 @@ -1,14 +1,39 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <reference id="ref.funchand"> <title>Fonctions</title> <titleabbrev>Fonctions</titleabbrev> - <partintro> - <para> + + <partintro> + <section id="funchand.intro"> + &reftitle.intro; + <para> Ces fonctions effectuent les manipulations liées à la gestion des fonctions. - </para> - </partintro> + </para> + </section> + + <section id="funchand.requirements"> + &reftitle.required; + &no.requirement; + </section> + + <section id="funchand.installation"> + &reftitle.install; + &no.install; + </section> + + <section id="funchand.configuration"> + &reftitle.runtime; + &no.config; + </section> + + <section id="funchand.constants"> + &reftitle.constants; + &no.constants; + </section> + + </partintro> &reference.funchand.functions; Index: phpdoc-fr/reference/funchand/functions/call-user-func-array.xml diff -u phpdoc-fr/reference/funchand/functions/call-user-func-array.xml:1.1 phpdoc-fr/reference/funchand/functions/call-user-func-array.xml:1.2 --- phpdoc-fr/reference/funchand/functions/call-user-func-array.xml:1.1 Sun Apr 14 20:28:46 2002 +++ phpdoc-fr/reference/funchand/functions/call-user-func-array.xml Mon Sep 22 09:25:06 2003 @@ -10,19 +10,19 @@ </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>mixed</type><methodname>call_user_func_array</methodname> - <methodparam><type>string</type><parameter>function_name</parameter></methodparam> - <methodparam choice="opt"><type>array</type><parameter>paramarr</parameter></methodparam> - </methodsynopsis> + <methodsynopsis> + <type>mixed</type><methodname>call_user_func_array</methodname> + <methodparam><type>callback</type><parameter>function</parameter></methodparam> + <methodparam choice="opt"><type>array</type><parameter>paramarr</parameter></methodparam> + </methodsynopsis> <para> <function>call_user_func_array</function> appelle la fonction utilisateur <parameter>function_name</parameter> avec les paramètres <parameter>paramarr</parameter>, rassemblés dans un tableau. - Par exemple: - <informalexample> + <example> + <title>Exemple avec <function>call_user_func_array</function></title> <programlisting role="php"> -<?php +<![CDATA[ function debug($var, $val) echo "***DEBUGGING\nVARIABLE: $var\nVALUE:"; if (is_array($val) || is_object($val) || is_resource($val)) @@ -31,14 +31,16 @@ echo "\n$val\n"; echo "***\n"; } + $c = mysql_connect(); -$host = $HTTP_SERVER_VARS["SERVER_NAME"]; +$host = $_SERVER["SERVER_NAME"]; + call_user_func_array ('debug', array("host", $host)); call_user_func_array ('debug', array("c", $c)); -call_user_func_array ('debug', array("HTTP_POST_VARS", $HTTP_POST_VARS)); -?> +call_user_func_array ('debug', array("_POST", $_POST)); +]]> </programlisting> - </informalexample> + </example> </para> <para> Voir aussi @@ -46,12 +48,6 @@ <function>call_user_method</function> et <function>call_user_method_array</function>. </para> - <note> - <para> - <function>call_user_func_array</function> a été ajouté - en version PHP 4.05. - </para> - </note> </refsect1> </refentry> Index: phpdoc-fr/reference/funchand/functions/call-user-func.xml diff -u phpdoc-fr/reference/funchand/functions/call-user-func.xml:1.1 phpdoc-fr/reference/funchand/functions/call-user-func.xml:1.2 --- phpdoc-fr/reference/funchand/functions/call-user-func.xml:1.1 Sun Apr 14 20:28:48 2002 +++ phpdoc-fr/reference/funchand/functions/call-user-func.xml Mon Sep 22 09:25:06 2003 @@ -10,30 +10,56 @@ </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>mixed</type><methodname>call_user_func</methodname> - <methodparam><type>string</type><parameter>function_name</parameter></methodparam> - <methodparam choice="opt"><type>mixed</type><parameter>parameter</parameter></methodparam> - <methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam> - </methodsynopsis> + <methodsynopsis> + <type>mixed</type><methodname>call_user_func</methodname> + <methodparam><type>callback</type><parameter>function</parameter></methodparam> + <methodparam choice="opt"><type>mixed</type><parameter>parameter</parameter></methodparam> + <methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam> + </methodsynopsis> <para> <function>call_user_func</function> appelle la fonction utilisateur <parameter>function_name</parameter>, et lui passe les paramètres <parameter>parameter</parameter>. - Par exemple : - <informalexample> + <example> + <title>Exemple avec <function>call_user_func</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function barbier ($type) { print "Vous vouliez une coupe $type, pas de problème"; } - call_user_func('barbier', "iroquois"); + + call_user_func('barbier', "à la one again"); call_user_func('barbier', "militaire"); call_user_func('barbier', "au bol"); -?> +?> +]]> </programlisting> - </informalexample> + </example> </para> + <para> + Les méthodes d'objets peuvent être appelées statiquement + en passant <literal>array($objectname, $methodname)</literal> au + paramètre <parameter>function</parameter>. + <example> + <title>Exemple avec <function>call_user_func</function> et une méthode de classe</title> + <programlisting role="php"> +<![CDATA[ +<?php +class maclasse { + function dit_bonjour() { + print "Bonjour!\n"; + } +} + +$classname = "maclasse"; + +call_user_func(array($classname,'dit_bonjour')); +?> +]]> + </programlisting> + </example> + </para> <para> Voir aussi <function>call_user_func_array</function>, Index: phpdoc-fr/reference/funchand/functions/create-function.xml diff -u phpdoc-fr/reference/funchand/functions/create-function.xml:1.2 phpdoc-fr/reference/funchand/functions/create-function.xml:1.3 --- phpdoc-fr/reference/funchand/functions/create-function.xml:1.2 Thu Aug 14 10:48:53 2003 +++ phpdoc-fr/reference/funchand/functions/create-function.xml Mon Sep 22 09:25:06 2003 @@ -34,14 +34,16 @@ Création d'une fonction anonyme avec <function>create_function</function> </title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $newfunc = create_function('$a,$b','return "ln($a) + ln($b) = ".log($a * $b);'); echo "Nouvelle fonction anonyme : $newfunc\n"; echo $newfunc(2,M_E)."\n"; // affichera : // Nouvelle fonction anonyme : lambda_1 // ln(2) + ln(2.718281828459) = 1.6931471805599 -?> +?> +]]> </programlisting> </example> Ou, pour pouvoir appliquer une fonction générique @@ -52,15 +54,17 @@ <function>create_function</function> </title> <programlisting role="php"> -<?php +<."\n"; } -// création d'une série de fonction mathématiques -$f1 = 'if ($a>=0) {return "b*a^2 = ".$b*sqrt($a);} else {return FALSE;}'; + +// Création d'une série de fonction mathématiques +$f1 = 'if ($a>=0) {return "b*a^2 = ".$b*sqrt($a);} else {return FALSE;}'; $f2 = "return \"min(b^2+a, a^2,b) = \".min(\$a*\$a+\$b,\$b*\$b+\$a);"; -$f3 = 'if ($a> 0 && $b != 0) {return "ln(a)/b = ".log($a)/$b;} else {return FALSE;}'; +$f3 = 'if ($a> 0 && $b != 0) {return "ln(a)/b = ".log($a)/$b;} else {return FALSE;}'; $farr = array( create_function('$x,$y', 'return "un peu de trigo : ".(sin($x) + $x*cos($y));'), create_function('$x,$y', 'return "une hypoténuse: ".sqrt($x*$x + $y*$y);'), @@ -68,55 +72,62 @@ create_function('$a,$b', $f2), create_function('$a,$b', $f3) ); + echo "\nUtilisation de la première liste de fonctions anonymes\n"; echo "paramétres: 2.3445, M_PI\n"; process(2.3445, M_PI, $farr); + // Maintenant une liste de fonction sur chaîne de caractères $garr = array( create_function('$b,$a','if (strncmp($a,$b,3) == 0) return "** \"$a\" '. 'et \"$b\"\n** Ces chaînes de ressemblent!! (regarde les trois premiers caractères)";'), create_function('$a,$b','; return "CRCs: ".crc32($a)." , ".crc32(b);'), - create_function('$a,$b','; return "similarité(a,b) = ".similar_text($a,$b,&$p)."($p%)";') + create_function('$a,$b','; return "similarité(a,b) = ".similar_text($a,$b,&$p)."($p%)";') ); echo "\nUtilisation de la secondes liste de fonctions anonymes\n"; process("Twas brilling and the slithy toves", "Twas the night", $garr); -?> +?> +]]> </programlisting> - </example> - Et lorsque vous utilisez le code ci-dessus, l'affichage va être - <informalexample> + <para> + Et lorsque vous utilisez le code ci-dessus, l'affichage sera + </para> <programlisting> +<![CDATA[ Utilisation de la première liste de fonctions anonymes paramétres: 2.3445, M_PI -Un peu de trigo: -1.6291725057799 -Une hypoténuse: 3.9199852871011 +un peu de trigo : -1.6291725057799 +une hypoténuse: 3.9199852871011 b*a^2 = 4.8103313314525 min(b^2+a, a^2,b) = 8.6382729035898 -ln(a/b) = 0.27122299212594 -Utilisation de la seconde liste de fonctions anonymes +ln(a)/b = 0.27122299212594 + +Utilisation de la secondes liste de fonctions anonymes ** "Twas the night" et "Twas brilling and the slithy toves" ** Ces chaînes de ressemblent!! (regarde les trois premiers caractères) CRCs: -725381282 , 1908338681 similarité(a,b) = 11(45.833333333333%) +]]> </programlisting> - </informalexample> + </example> Mais l'utilisation la plus courante des fonctions lambda est la fonction de callback, par exemple lors de l'utilisation de <function>array_walk</function> ou <function>usort</function> <example> <title>Utilisation de fonctions anonymes comme fonction de callback</title> <programlisting role="php"> -<?php +<![CDATA[ +<?php $av = array("la ","une ","cette ","une certaine "); -array_walk($av, create_function('&$v,$k','$v = $v."maison";')); -print_r($av); // En PHP 3 utilisez <function>var_dump</function> +array_walk($av, create_function('&$v,$k','$v = $v."maison";')); +print_r($av); // En PHP 3 utilisez var_dump() // affiche: // Array // ( -// [0] => la maison -// [1] => une maison -// [2] => cette maison -// [3] => une certaine maison +// [0] => la maison +// [1] => une maison +// [2] => cette maison +// [3] => une certaine maison // ) // un tableau de chaîne classé par taille $sv = array("petite","moyenne","tres longue","vraiment tres longue"); @@ -124,10 +135,10 @@ // affiche: // Array // ( -// [0] => petite -// [1] => moyenne -// [2] => tres longue -// [3] => vraiment tres longue +// [0] => petite +// [1] => moyenne +// [2] => tres longue +// [3] => vraiment tres longue // ) // Tri par ordre de taille décroissant usort($sv, create_function('$a,$b','return strlen($b) - strlen($a);')); @@ -135,12 +146,13 @@ // outputs: // Array // ( -// [0] => vraiment tres longue -// [1] => tres longue -// [2] => moyenne -// [3] => petite +// [0] => vraiment tres longue +// [1] => tres longue +// [2] => moyenne +// [3] => petite // ) -?> +?> +]]> </programlisting> </example> </para> Index: phpdoc-fr/reference/funchand/functions/func-get-arg.xml diff -u phpdoc-fr/reference/funchand/functions/func-get-arg.xml:1.1 phpdoc-fr/reference/funchand/functions/func-get-arg.xml:1.2 --- phpdoc-fr/reference/funchand/functions/func-get-arg.xml:1.1 Sun Apr 14 20:28:48 2002 +++ phpdoc-fr/reference/funchand/functions/func-get-arg.xml Mon Sep 22 09:25:06 2003 @@ -25,23 +25,26 @@ <simpara> Si <parameter>arg_num</parameter> est plus grand que le nombre d'arguments passés, une alerte est générée - et la fonction retourne <literal>FALSE</literal>. + et la fonction retourne &false;. </simpara> <para> - <informalexample> + <example> + <title>Exemple avec <function>func_get_arg</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function foo() { $numargs = func_num_args(); - echo "Nombre d'arguments: $numargs<br>\n"; - if ($numargs >= 2) { - echo "Le second argument est: " . func_get_arg (1) . "<br>\n"; + echo "Nombre d'arguments: $numargs<BR>\n"; + if ($numargs >= 2) { + echo "Le second argument est: " . func_get_arg (1) . "<BR>\n"; } } foo(1, 2, 3); -?> +?> +]]> </programlisting> - </informalexample> + </example> </para> <simpara> <function>func_get_arg</function> peut être utilisé Index: phpdoc-fr/reference/funchand/functions/func-get-args.xml diff -u phpdoc-fr/reference/funchand/functions/func-get-args.xml:1.1 phpdoc-fr/reference/funchand/functions/func-get-args.xml:1.2 --- phpdoc-fr/reference/funchand/functions/func-get-args.xml:1.1 Sun Apr 14 20:28:48 2002 +++ phpdoc-fr/reference/funchand/functions/func-get-args.xml Mon Sep 22 09:25:06 2003 @@ -12,7 +12,7 @@ <title>Description</title> <methodsynopsis> <type>array</type><methodname>func_get_args</methodname> - <methodparam><type>void</type><parameter/></methodparam> + <void/> </methodsynopsis> <simpara> <function>func_get_args</function> retourne un tableau dont @@ -22,24 +22,27 @@ alerte si elle est appelée hors d'une fonction. </simpara> <para> - <informalexample> + <example> + <title>Exemple avec <function>func_get_args</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function foo() { $numargs = func_num_args(); - echo "Nombre d'arguments: $numargs<br>\n"; - if ($numargs >= 2) { - echo "Le second argument est: " . func_get_arg (1) . "<br>\n"; + echo "Nombre d'arguments: $numargs<BR>\n"; + if ($numargs >= 2) { + echo "Le second argument est : " . func_get_arg (1) . "<BR>\n"; } $arg_list = func_get_args(); - for ($i = 0; $i < $numargs; $i++) { - echo "L'argument $i est: " . $arg_list[$i] . "<br>\n"; + for ($i = 0; $i < $numargs; $i++) { + echo "L'argument $i est : " . $arg_list[$i] . "<BR>\n"; } } foo(1, 2, 3); -?> +?> +]]> </programlisting> - </informalexample> + </example> </para> <simpara> <function>func_get_arg</function> peut être utilisé Index: phpdoc-fr/reference/funchand/functions/func-num-args.xml diff -u phpdoc-fr/reference/funchand/functions/func-num-args.xml:1.1 phpdoc-fr/reference/funchand/functions/func-num-args.xml:1.2 --- phpdoc-fr/reference/funchand/functions/func-num-args.xml:1.1 Sun Apr 14 20:28:49 2002 +++ phpdoc-fr/reference/funchand/functions/func-num-args.xml Mon Sep 22 09:25:06 2003 @@ -12,7 +12,7 @@ <title>Description</title> <methodsynopsis> <type>int</type><methodname>func_num_args</methodname> - <methodparam><type>void</type><parameter/></methodparam> + <void/> </methodsynopsis> <simpara> <function>func_num_args</function> retourne le nombre d'arguments @@ -22,17 +22,20 @@ hors d'une fonction. </simpara> <para> - <informalexample> + <example> + <title>Exemple avec <function>func_num_args</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function foo() { $numargs = func_num_args(); echo "Nombre d'arguments: $numargs\n"; } foo (1, 2, 3); // affiche 'Nombre d'arguments: 3' -?> +?> +]]> </programlisting> - </informalexample> + </example> </para> <simpara> <function>func_get_arg</function> peut être utilisé Index: phpdoc-fr/reference/funchand/functions/function-exists.xml diff -u phpdoc-fr/reference/funchand/functions/function-exists.xml:1.2 phpdoc-fr/reference/funchand/functions/function-exists.xml:1.3 --- phpdoc-fr/reference/funchand/functions/function-exists.xml:1.2 Tue Aug 13 22:19:32 2002 +++ phpdoc-fr/reference/funchand/functions/function-exists.xml Mon Sep 22 09:25:06 2003 @@ -5,37 +5,40 @@ <refnamediv> <refname>function_exists</refname> <refpurpose> - Indique si une fonction est définie. + Indique si une fonction est définie </refpurpose> </refnamediv> <refsect1> <title>Description</title> <methodsynopsis> - <type>boolean</type><methodname>function_exists</methodname> + <type>bool</type><methodname>function_exists</methodname> <methodparam><type>string</type><parameter>function_name</parameter></methodparam> </methodsynopsis> <para> <function>function_exists</function> vérifie la liste des - fonctions définies par l'utilisateur, et retourne - &true; si <parameter>function_name</parameter> - y est trouvé, &false;sinon. - <informalexample> + fonctions définies par l'utilisateur. + &return.success; + <example> + <title>Exemple avec <function>function_exists</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php if (function_exists('imap_open')) { - echo "Les fonctions IMAP sont disponibles.<br>\n"; + echo "Les fonctions IMAP sont disponibles.<BR>\n"; } else { - echo "Les fonctions IMAP ne sont pas disponibles.<br>\n"; + echo "Les fonctions IMAP ne sont pas disponibles.<BR>\n"; } -?> +?> +]]> </programlisting> - </informalexample> + </example> Notez qu'une fonction peut exister, même si elle est indisponible, à cause de la configuration ou des options de compilation. </para> <para> Voir aussi - <function>method_exists</function>. + <function>method_exists</function> et + <function>get_defined_functions</function>. </para> </refsect1> </refentry> Index: phpdoc-fr/reference/funchand/functions/get-defined-functions.xml diff -u phpdoc-fr/reference/funchand/functions/get-defined-functions.xml:1.1 phpdoc-fr/reference/funchand/functions/get-defined-functions.xml:1.2 --- phpdoc-fr/reference/funchand/functions/get-defined-functions.xml:1.1 Sun Apr 14 20:28:49 2002 +++ phpdoc-fr/reference/funchand/functions/get-defined-functions.xml Mon Sep 22 09:25:06 2003 @@ -12,7 +12,7 @@ <title>Description</title> <methodsynopsis> <type>array</type><methodname>get_defined_functions</methodname> - <methodparam><type>void</type><parameter/></methodparam> + <void/> </methodsynopsis> <para> <function>get_defined_functions</function> retourne un tableau multi- @@ -21,48 +21,52 @@ définie par l'utilisateur. Les noms des fonctions internes sont accessibles via <varname>$arr["internal"]</varname>, et les fonctions utilisateur sont accessibles via <varname>$arr["user"]</varname>. - <informalexample> + <example> + <title>Exemple avec <function>get_defined_functions</function></title> <programlisting role="php"> -<?php +<![CDATA[ +<?php function maligne($id, $data) { - return "<tr><th>$id</th><td>$data</td></tr>\n"; + return "<tr><th>$id</th><td>$data</td></tr>\n"; } $arr = get_defined_functions(); print_r($arr); -?> +?> +]]> </programlisting> - </informalexample> - </para> <para> Ce script va afficher : - <informalexample> + </para> <programlisting> +<![CDATA[ Array ( - [internal] => Array + [internal] => Array ( - [0] => zend_version - [1] => func_num_args - [2] => func_get_arg - [3] => func_get_args - [4] => strlen - [5] => strcmp - [6] => strncmp + [0] => zend_version + [1] => func_num_args + [2] => func_get_arg + [3] => func_get_args + [4] => strlen + [5] => strcmp + [6] => strncmp ... - [750] => bcscale - [751] => bccomp + [750] => bcscale + [751] => bccomp ) - [user] => Array + [user] => Array ( - [0] => maligne + [0] => maligne ) ) +]]> </programlisting> - </informalexample> + </example> </para> <para> Voir aussi - <function>get_defined_vars</function>. + <function>get_defined_vars</function> et + <function>get_defined_constants</function>. </para> </refsect1> </refentry> Index: phpdoc-fr/reference/funchand/functions/register-shutdown-function.xml diff -u phpdoc-fr/reference/funchand/functions/register-shutdown-function.xml:1.1 phpdoc-fr/reference/funchand/functions/register-shutdown-function.xml:1.2 --- phpdoc-fr/reference/funchand/functions/register-shutdown-function.xml:1.1 Sun Apr 14 20:28:49 2002 +++ phpdoc-fr/reference/funchand/functions/register-shutdown-function.xml Mon Sep 22 09:25:06 2003 @@ -10,23 +10,47 @@ </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>int</type><methodname>register_shutdown_function</methodname> - <methodparam><type>string</type><parameter>func</parameter></methodparam> - </methodsynopsis> + <methodsynopsis> + <type>void</type><methodname>register_shutdown_function</methodname> + <methodparam><type>callback</type><parameter>function</parameter></methodparam> + </methodsynopsis> <simpara> <function>register_shutdown_function</function> enregistre la fonction <parameter>func</parameter> pour exécution à l'extinction du script. </simpara> - <para> - Erreur courante : - </para> - <simpara> - Etant donné qu'aucun affichage n'est possible depuis la fonction - <parameter>func</parameter>, vous ne pouvez pas y mettre d'informations - de débuggage par <function>print</function> ou <function>echo</function>! - </simpara> + <para> + Plusieurs appels à <function>register_shutdown_function</function> sont + possibles dans le même script, et les fonctions seront appelées dans le + même ordre que celui dans elles sont enregistrées. SI vous appelez + <function>exit</function> durant l'une des fonctions d'extinction, + le processus sera définitivement arrété, sans que les autres fonctions + soient appelées. + </para> + <para> + Les fonctions d'extinction sont appelées après la fin de la requête + (notamment les buffers ont été vidés), ce qui fait qu'il est impossible + d'afficher du texte depuis cette fonction, avec <function>echo</function> ou + <function>print</function>, ou encore de lire le contenu des buffers + avec <function>ob_get_contents</function>. + </para> + <note> + <para> + Typiquement, les fonctions non définies causent des + erreurs fatales en &php;, mais lorsque la fonction + <parameter>function</parameter> est appelée avec + <function>register_shutdown_function</function> en étant non définie, + une erreur de type <constant>E_WARNING</constant> est générée. De plus, + pour des raisons internes à &php; cette erreur va être indiquée + comme <literal>Unknown at line #0</literal>. + </para> + </note> + <para> + Voir aussi + <link linkend="ini.auto-append-file">auto_append_file</link>, + <function>exit</function>, et la section sur la + <link linkend="features.connection-handling">gestion des connexions</link>. + </para> </refsect1> </refentry> Index: phpdoc-fr/reference/funchand/functions/register-tick-function.xml diff -u phpdoc-fr/reference/funchand/functions/register-tick-function.xml:1.1 phpdoc-fr/reference/funchand/functions/register-tick-function.xml:1.2 --- phpdoc-fr/reference/funchand/functions/register-tick-function.xml:1.1 Sun Apr 14 20:28:49 2002 +++ phpdoc-fr/reference/funchand/functions/register-tick-function.xml Mon Sep 22 09:25:06 2003 @@ -10,16 +10,39 @@ </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>void</type><methodname>register_tick_function</methodname> - <methodparam><type>string</type><parameter>func</parameter></methodparam> - <methodparam choice="opt"><type>mixed</type><parameter>arg</parameter></methodparam> - </methodsynopsis> + <methodsynopsis> + <type>void</type><methodname>register_tick_function</methodname> + <methodparam><type>callback</type><parameter>function</parameter></methodparam> + <methodparam choice="opt"><type>mixed</type><parameter>arg</parameter></methodparam> + </methodsynopsis> <simpara> <function>register_tick_function</function> enregistre la fonction - <parameter>func</parameter> pour être exécutée à chaque fois qu'un + <parameter>func</parameter> pour être exécutée + à chaque fois qu'un <link linkend="control-structures.declare">tick</link> est appelé. </simpara> + <para> + <example> + <title>Exemple avec <function>register_tick_function</function></title> + <programlisting role="php"> +<![CDATA[ +<?php +// Utilisation d'une fonction de callback +register_tick_function('ma_function', TRUE); + +// Utilisation d'une méthode d'objet +$objet = new ma_classe(); +register_tick_function(array(&$objet, 'ma_methode'), TRUE); +?> +]]> + </programlisting> + </example> + </para> + <para> + Voir aussi + <function>declare</function> et + <function>unregister_tick_function</function>. + </para> </refsect1> </refentry> Index: phpdoc-fr/reference/funchand/functions/unregister-tick-function.xml diff -u phpdoc-fr/reference/funchand/functions/unregister-tick-function.xml:1.1 phpdoc-fr/reference/funchand/functions/unregister-tick-function.xml:1.2 --- phpdoc-fr/reference/funchand/functions/unregister-tick-function.xml:1.1 Sun Apr 14 20:28:49 2002 +++ phpdoc-fr/reference/funchand/functions/unregister-tick-function.xml Mon Sep 22 09:25:06 2003 @@ -10,11 +10,10 @@ </refnamediv> <refsect1> <title>Description</title> - <methodsynopsis> - <type>void</type><methodname>unregister_tick_function</methodname> - <methodparam><type>string</type><parameter>func</parameter></methodparam> - <methodparam choice="opt"><type>mixed</type><parameter>arg</parameter></methodparam> - </methodsynopsis> + <methodsynopsis> + <type>void</type><methodname>unregister_tick_function</methodname> + <methodparam><type>string</type><parameter>function_name</parameter></methodparam> + </methodsynopsis> <simpara> <function>unregister_tick_function</function> annule l'exécution automatique de <parameter>func</parameter> à chaque