From a5431941484bd5738321d1860093d7a961ef9fe8 Mon Sep 17 00:00:00 2001 From: Jeroen van Wolffelaar Date: Wed, 27 Jun 2001 12:04:49 +0000 Subject: [PATCH] 'd var.xml, improved documenation on serialize (not yet 'ready', though) git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@50267 c90b9560-bf6c-de11-be94-00142212c4b1 --- functions/var.xml | 105 +++++++++++++++++++++++++++------------------- 1 file changed, 63 insertions(+), 42 deletions(-) diff --git a/functions/var.xml b/functions/var.xml index a8b58b5341..0cd72b3123 100644 --- a/functions/var.xml +++ b/functions/var.xml @@ -128,28 +128,28 @@ if (!isset($var)) { // evaluates false Possibles values for the returned string are: - "boolean" (since PHP 4) + "boolean" (since PHP 4) - "integer" + "integer" - "double" + "double" - "string" + "string" - "array" + "array" - "object" + "object" - "resource" (since PHP 4) + "resource" (since PHP 4) - "NULL" (since PHP 4) + "NULL" (since PHP 4) "user function" (PHP 3 only, deprecated) @@ -246,8 +246,9 @@ print_r(array_keys(get_defined_vars())); - This function returns a string representing the type of the resource - passed to it. If the paramater is not a valid resource, it + This function returns a string representing the type of the + resource passed to it. If the paramater is not a + valid resource, it generates an error. @@ -285,13 +286,13 @@ echo get_resource_type($doc->doc)."\n"; - Returns the integer value of var, + Returns the integer value of var, using the specified base for the conversion (the default is base 10). var may be any scalar type. You cannot use - intval on arrays or objects. + intval on arrays or objects. @@ -323,7 +324,7 @@ echo get_resource_type($doc->doc)."\n"; - Returns true if var is an array, false + Returns true if var is an array, false otherwise. @@ -360,7 +361,7 @@ echo get_resource_type($doc->doc)."\n"; Returns true if the var parameter is - a boolean. + a boolean. See also is_array, @@ -390,7 +391,7 @@ echo get_resource_type($doc->doc)."\n"; - Returns true if var is a double, + Returns true if var is a double, false otherwise. @@ -512,7 +513,8 @@ echo get_resource_type($doc->doc)."\n"; - Returns true if var is an integer (long), + Returns true if var is an integer + (long), false otherwise. @@ -545,7 +547,8 @@ echo get_resource_type($doc->doc)."\n"; - Returns true if var is null, false otherwise. + Returns true if var is null, + false otherwise. See also is_bool, @@ -610,8 +613,8 @@ echo get_resource_type($doc->doc)."\n"; - Returns true if var is an object, false - otherwise. + Returns true if var is an object, + false otherwise. See also is_bool, @@ -678,15 +681,13 @@ echo get_resource_type($doc->doc)."\n"; is_resource returns true if the variable - given by the var parameter is a resource, - otherwise it returns false. - - - Resources are things like file or database result handles that - are allocated and freed by internal PHP functions and that may - need some cleanup when they are no longer in use but haven't been - freed by user code. + given by the var parameter is a + resource, otherwise it returns false. + + See the documentation on the resource-type for + more information. + @@ -715,10 +716,13 @@ echo get_resource_type($doc->doc)."\n"; otherwise it returns false. - Scalar variables are those containing an integer, float, string - or boolean. For example: + Scalar variables are those containing an integer, + float, string or boolean. + For example: + function show_var($var) { if (is_scalar($var)) echo $var; @@ -747,7 +751,7 @@ show_var($proteins) - is_scalar does not consider resource + is_scalar does not consider resource type values to be scalar values. This behavior is intentional: Resources are abstract datatypes which are currently based on integers. This implementation detail should not be relied upon, @@ -756,8 +760,7 @@ show_var($proteins) - This function was added to the CVS code after the release of PHP - 4.0.4pl1 + Since 4.0.5 @@ -790,7 +793,7 @@ show_var($proteins) - Returns true if var is a string, + Returns true if var is a string, false otherwise. @@ -867,10 +870,11 @@ print isset ($foo); // FALSE This function displays information about the values of variables - in a way that's readable by humans. If given a string, integer - or double, the value itself will be printed. If given an array, + in a way that's readable by humans. If given a string, + integer or double, the value itself will be + printed. If given an array, values will be presented in a format that shows keys and - elements. Similar notation is used for objects. + elements. Similar notation is used for objects. Remember that print_r will move the array @@ -894,9 +898,11 @@ print_r ($a); - This function will continue forever if given an array or object + This function will continue forever if given an array + or object that contains a direct or indirect reference to itself or that - contains an array or object on a deeper level that does so. + contains an array or object on a deeper + level that does so. This is especially true for print_r($GLOBALS), as $GLOBALS is itself a global variable and contains a reference to itself as such. @@ -932,10 +938,23 @@ print_r ($a); To make the serialized string into a PHP value again, use unserialize. serialize - handles the types integer, double, - string, array (multidimensional) and - object. + handles all types, except the resource-type. + You can even serialize arrays that contain + references to itself. References inside the array/object you + are serializeing will also be stored. + In PHP 3, object properties will be serialized, but methods are @@ -1041,7 +1060,9 @@ settype($bar, "string"); // $bar is now "1" (string) - Returns the string value of var. + Returns the string value of var. + See the documentation on string for more information + on converting to string. var may be any scalar type. You cannot use