com doc/fr: Apply commit 3801e08ff8007bcdc2fb2508f2065d130bfec58f: language/types/array.xml
[email protected] (George Peter Banyard) Wed, 24 Feb 2021 17:45:13 +0000
| Newsgroups | php.doc.fr |
|---|---|
| Message-ID | <[email protected]> |
Commit: f8ee3643d7149618739e3fdbd547640b19dfd6b8 Author: George Peter Banyard <[email protected]> Wed, 24 Feb 2021 15:30:14 +0000 Parents: c8c51dfb30c8d81566bb5eba0499967ed5340bd5 Branches: master Link: http://git.php.net/?p=doc/fr.git;a=commitdiff;h=f8ee3643d7149618739e3fdbd547640b19dfd6b8 Log: Apply commit 3801e08ff8007bcdc2fb2508f2065d130bfec58f Added protected property example for Object To Array conversion Changed paths: M language/types/array.xml Diff: diff --git a/language/types/array.xml b/language/types/array.xml index f055a9ef56..44c7be1551 100644 --- a/language/types/array.xml +++ b/language/types/array.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <!-- $Revision$ --> -<!-- EN-Revision: 6de2e5772f11997fb9a8c0fa2406fbb2c73b3579 Maintainer: yannick Status: ready --> +<!-- EN-Revision: 3ba291b86ab677a291807caaf69898b4a3bd11e1 Maintainer: yannick Status: ready --> <!-- Reviewed: no --> <!-- CREDITS: DavidA --> @@ -802,7 +802,42 @@ $error_descriptions[8] = "This is just an informal notice"; avec une légère exception : les variables ayant un nom sous forme d'entier sont inaccessible; les variables privées auront le nom de la classe ajouté au nom de la variable ; les variables protégées auront un '*' ajouté - au nom de la variable. Ce comportement peut amener à des résultats inattendus : + au nom de la variable. + Ces valeurs préfixés ont des octets <literal>NUL</literal> des deux côtés. + </para> + + <informalexample> + <programlisting role="php"> +<![CDATA[ +<?php +class A { + private $B; + protected $C; + public $D; + function __construct() + { + $this->{1} = null; + } +} +var_export((array) new A()); +?> +]]> + </programlisting> + &example.outputs; + <screen> +<![CDATA[ +array ( + '' . "\0" . 'A' . "\0" . 'B' => NULL, + '' . "\0" . '*' . "\0" . 'C' => NULL, + 'D' => NULL, + 1 => NULL, +) +]]> + </screen> + </informalexample> + + <para> + Ces octets <literal>NUL</literal> peuvent amener à des résultats inattendus : </para> <informalexample> @@ -823,6 +858,19 @@ var_dump((array) new B()); ?> ]]> </programlisting> + &example.outputs; + <screen> +<![CDATA[ +array(3) { + ["BA"]=> + NULL + ["AA"]=> + NULL + ["AA"]=> + NULL +} +]]> + </screen> </informalexample> <para>