Adding info on conversion to objects and resources,

removed these info from the juggling part


git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@103072 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Gabor Hojtsy 2002-11-09 13:50:36 +00:00
parent 4b58c2c729
commit 5de0321db9

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.96 $ -->
<!-- $Revision: 1.97 $ -->
<chapter id="language.types">
<title>Types</title>
@ -1729,8 +1729,27 @@ $bar->do_foo();
For a full discussion, please read the section <link
linkend="language.oop">Classes and Objects</link>.
</simpara>
</sect2>
<sect2 id="language.types.object.casting">
<title>Converting to object</title>
<para>
If an object is converted to an object, it is not modified. If a value
of any other type is converted to an object, a new instace of the
<literal>stdClass</literal> built in class is created. If the value
was null, the new instance will be empty. For any other value, a
member variable named <literal>scalar</literal> will contain the
value.
<informalexample>
<programlisting role="php">
$obj = (object) 'ciao';
echo $obj-&gt;scalar; // outputs 'ciao'
</programlisting>
</informalexample>
</para>
</sect2>
</sect1>
<sect1 id="language.types.resource">
@ -1743,7 +1762,6 @@ $bar->do_foo();
See the <link linkend="resource">appendix</link>
for a listing of all these
functions and the corresponding resource types.
</para>
<note>
@ -1752,6 +1770,16 @@ $bar->do_foo();
</simpara>
</note>
<sect2 id="language.types.resource.casting">
<title>Converting to resource</title>
<para>
As resource types hold special handlers to opened
files, database connections, image canvas areas and
the like, you cannot convert any value to a resource.
</para>
</sect2>
<sect2 id="language.types.resource.self-destruct">
<title>Freeing resources</title>
@ -1767,11 +1795,11 @@ $bar->do_foo();
function.
<note>
<simpara>
Persistent database-links are special, they
Persistent database links are special, they
are <emphasis>not</emphasis> destroyed by the
gc. See also <link
garbage collector. See also the section about <link
linkend="features.persistent-connections">persistent
links</link>
connections</link>.
</simpara>
</note>
</para>
@ -1817,8 +1845,7 @@ $bar->do_foo();
<title>Syntax</title>
<para>
There is only one value of type &null;, and that is
the case-insensitive keyword
&null;.
the case-insensitive keyword &null;.
<informalexample>
<programlisting role="php">
$var = NULL;
@ -2119,7 +2146,6 @@ if ($fst === $str) {
<simpara><link linkend="language.types.array.casting">Converting to
array</link></simpara>
</listitem>
<!-- don't exist yet
<listitem>
<simpara><link linkend="language.types.object.casting">Converting to
object</link></simpara>
@ -2128,28 +2154,14 @@ if ($fst === $str) {
<simpara><link linkend="language.types.resource.casting">Converting to
resource</link></simpara>
</listitem>
<!-- don't exist yet
<listitem>
<simpara><link linkend="language.types.null.casting">Converting to
&null;</link></simpara>
</listitem>
-->
</itemizedlist>
</para>
<para>
<!-- TODO: move to 'converting to object' -->
When casting from a scalar or a string variable to an object, the
variable will become an attribute of the object; the attribute
name will be 'scalar':
<informalexample>
<programlisting role="php">
$var = 'ciao';
$obj = (object) $var;
echo $obj-&gt;scalar; // outputs 'ciao'
</programlisting>
</informalexample>
</para>
</sect2>
</sect1>