mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Fix #38935, document changes in PHP5 when casting objects to arrays.
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@220546 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
972ae5ee78
commit
eba4fa6128
1 changed files with 28 additions and 2 deletions
|
@ -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 @@ $error_descriptions[8] = "This is just an informal notice";
|
|||
<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>
|
||||
|
|
Loading…
Reference in a new issue