cvs: phpdoc /en/language types.xml

From: Date: Tue, 26 Sep 2006 00:37:57 +0000
Subject: cvs: phpdoc /en/language types.xml
Groups: php.doc 
Request: Send a blank email to phpdoc+get-969374097@lists.php.net to get a copy of this message
joey Tue Sep 26 00:37:57 2006 UTC Modified files: /phpdoc/en/language types.xml Log: Fix #38935, document changes in PHP5 when casting objects to arrays. http://cvs.php.net/viewvc.cgi/phpdoc/en/language/types.xml?r1=1.167&r2=1.168&diff_format=u Index: phpdoc/en/language/types.xml diff -u phpdoc/en/language/types.xml:1.167 phpdoc/en/language/types.xml:1.168 --- phpdoc/en/language/types.xml:1.167 Thu Aug 31 01:57:26 2006 +++ phpdoc/en/language/types.xml Tue Sep 26 00:37:57 2006 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.167 $ --> +<!-- $Revision: 1.168 $ --> <chapter id="language.types"> <title>Types</title> @@ -1820,7 +1820,33 @@ <para> If you convert an <type>object</type> to an array, you get the properties (member variables) of that object as the array's elements. - The keys are the member variable names. + The keys are the member variable names with a few notable exceptions: + private variables have the class name prepended to the variable name; + protected variables have a '*' prepended to the variable name. + These prepended values have null bytes on either side. This can result + in some unexpected behaviour. + <informalexample> + <programlisting role="php"> +<![CDATA[ +<?php + +class A { + private $A; // This will become '\0A\0A' +} + +class B extends A { + private $A; // This will become '\0B\0A' + public $AA; // This will become 'AA' +} + +var_dump((array) new B()); +?> +]]> + </programlisting> + </informalexample> + + The above will appear to have two keys named 'AA', although one + of them is actually named '\0A\0A'. </para> <para>

« previous php.doc (#969374097) next »