mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
Added a note about array to object casting
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@335216 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
60e8e031cf
commit
2927fdd599
1 changed files with 20 additions and 3 deletions
|
@ -45,9 +45,26 @@ $bar->do_foo();
|
|||
modified. If a value of any other type is converted to an
|
||||
<type>object</type>, a new instance of the <literal>stdClass</literal>
|
||||
built-in class is created. If the value was &null;, the new instance will be
|
||||
empty. <type>Array</type>s convert to an <type>object</type> with properties
|
||||
named by keys, and corresponding values. For any other value, a member
|
||||
variable named <literal>scalar</literal> will contain the value.
|
||||
empty. An <type>array</type> converts to an <type>object</type> with properties
|
||||
named by keys and corresponding values, with the exception of numeric keys which
|
||||
will be inaccessible unless iterated.
|
||||
</para>
|
||||
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$obj = (object) array('1' => 'foo');
|
||||
var_dump(isset($obj->{'1'})); // outputs 'bool(false)'
|
||||
var_dump(key($obj)); // outputs 'int(1)'
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
|
||||
<para>
|
||||
For any other value, a member variable named <literal>scalar</literal> will contain
|
||||
the value.
|
||||
</para>
|
||||
|
||||
<informalexample>
|
||||
|
|
Loading…
Reference in a new issue