From 5de0321db9b37e3dd8b5a8abb7e9cef294369675 Mon Sep 17 00:00:00 2001 From: Gabor Hojtsy Date: Sat, 9 Nov 2002 13:50:36 +0000 Subject: [PATCH] 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 --- language/types.xml | 60 +++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/language/types.xml b/language/types.xml index 7ca6dc2ca5..042c17b8ea 100644 --- a/language/types.xml +++ b/language/types.xml @@ -1,5 +1,5 @@ - + Types @@ -1729,8 +1729,27 @@ $bar->do_foo(); For a full discussion, please read the section Classes and Objects. - + + + Converting to object + + + 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 + stdClass built in class is created. If the value + was null, the new instance will be empty. For any other value, a + member variable named scalar will contain the + value. + + +$obj = (object) 'ciao'; +echo $obj->scalar; // outputs 'ciao' + + + + + @@ -1743,7 +1762,6 @@ $bar->do_foo(); See the appendix for a listing of all these functions and the corresponding resource types. - @@ -1752,6 +1770,16 @@ $bar->do_foo(); + + Converting to resource + + + 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. + + + Freeing resources @@ -1767,11 +1795,11 @@ $bar->do_foo(); function. - Persistent database-links are special, they + Persistent database links are special, they are not destroyed by the - gc. See also persistent - links + connections. @@ -1817,8 +1845,7 @@ $bar->do_foo(); Syntax There is only one value of type &null;, and that is - the case-insensitive keyword - &null;. + the case-insensitive keyword &null;. $var = NULL; @@ -2119,7 +2146,6 @@ if ($fst === $str) { Converting to array - - - - - 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': - - -$var = 'ciao'; -$obj = (object) $var; -echo $obj->scalar; // outputs 'ciao' - - - -