mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
<type>'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
This commit is contained in:
parent
f53dce95c0
commit
a543194148
1 changed files with 63 additions and 42 deletions
|
@ -128,28 +128,28 @@ if (!isset($var)) { // evaluates false
|
|||
Possibles values for the returned string are:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>"boolean" (since PHP 4)</simpara>
|
||||
<simpara>"<type>boolean</type>" (since PHP 4)</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>"integer"</simpara>
|
||||
<simpara>"<type>integer</type>"</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>"double"</simpara>
|
||||
<simpara>"<type>double</type>"</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>"string"</simpara>
|
||||
<simpara>"<type>string</type>"</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>"array"</simpara>
|
||||
<simpara>"<type>array</type>"</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>"object"</simpara>
|
||||
<simpara>"<type>object</type>"</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>"resource" (since PHP 4)</simpara>
|
||||
<simpara>"<type>resource</type>" (since PHP 4)</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>"NULL" (since PHP 4)</simpara>
|
||||
<simpara>"<type>NULL</type>" (since PHP 4)</simpara>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>"user function" (PHP 3 only, deprecated)</simpara>
|
||||
|
@ -246,8 +246,9 @@ print_r(array_keys(get_defined_vars()));
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
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
|
||||
<type>resource</type> passed to it. If the paramater is not a
|
||||
valid <type>resource</type>, it
|
||||
generates an error.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
|
@ -285,13 +286,13 @@ echo get_resource_type($doc->doc)."\n";
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<simpara>
|
||||
Returns the integer value of <parameter>var</parameter>,
|
||||
Returns the <type>integer</type> value of <parameter>var</parameter>,
|
||||
using the specified base for the conversion (the default is
|
||||
base 10).
|
||||
</simpara>
|
||||
<simpara>
|
||||
<parameter>var</parameter> may be any scalar type. You cannot use
|
||||
<function>intval</function> on arrays or objects.
|
||||
<function>intval</function> on <type>array</type>s or <type>object</type>s.
|
||||
</simpara>
|
||||
<note>
|
||||
<para>
|
||||
|
@ -323,7 +324,7 @@ echo get_resource_type($doc->doc)."\n";
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns true if <parameter>var</parameter> is an array, false
|
||||
Returns true if <parameter>var</parameter> is an <type>array</type>, false
|
||||
otherwise.
|
||||
</para>
|
||||
<para>
|
||||
|
@ -360,7 +361,7 @@ echo get_resource_type($doc->doc)."\n";
|
|||
</funcsynopsis>
|
||||
<para>
|
||||
Returns true if the <parameter>var</parameter> parameter is
|
||||
a boolean.
|
||||
a <type>boolean</type>.
|
||||
</para>
|
||||
<para>
|
||||
See also <function>is_array</function>,
|
||||
|
@ -390,7 +391,7 @@ echo get_resource_type($doc->doc)."\n";
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns true if <parameter>var</parameter> is a double,
|
||||
Returns true if <parameter>var</parameter> is a <type>double</type>,
|
||||
false otherwise.
|
||||
</para>
|
||||
<para>
|
||||
|
@ -512,7 +513,8 @@ echo get_resource_type($doc->doc)."\n";
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns true if <parameter>var</parameter> is an integer (long),
|
||||
Returns true if <parameter>var</parameter> is an <type>integer</type>
|
||||
(long),
|
||||
false otherwise.
|
||||
</para>
|
||||
<para>
|
||||
|
@ -545,7 +547,8 @@ echo get_resource_type($doc->doc)."\n";
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns true if <parameter>var</parameter> is null, false otherwise.
|
||||
Returns true if <parameter>var</parameter> is <type>null</type>,
|
||||
false otherwise.
|
||||
</para>
|
||||
<para>
|
||||
See also <function>is_bool</function>,
|
||||
|
@ -610,8 +613,8 @@ echo get_resource_type($doc->doc)."\n";
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns true if <parameter>var</parameter> is an object, false
|
||||
otherwise.
|
||||
Returns true if <parameter>var</parameter> is an <type>object</type>,
|
||||
false otherwise.
|
||||
</para>
|
||||
<para>
|
||||
See also <function>is_bool</function>,
|
||||
|
@ -678,15 +681,13 @@ echo get_resource_type($doc->doc)."\n";
|
|||
</funcsynopsis>
|
||||
<para>
|
||||
<function>is_resource</function> returns true if the variable
|
||||
given by the <parameter>var</parameter> parameter is a resource,
|
||||
otherwise it returns false.
|
||||
</para>
|
||||
<para>
|
||||
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 <parameter>var</parameter> parameter is a
|
||||
<type>resource</type>, otherwise it returns false.
|
||||
</para>
|
||||
<para>
|
||||
See the documentation on the <type>resource</type>-type for
|
||||
more information.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
|
@ -715,10 +716,13 @@ echo get_resource_type($doc->doc)."\n";
|
|||
otherwise it returns false.
|
||||
</para>
|
||||
<para>
|
||||
Scalar variables are those containing an integer, float, string
|
||||
or boolean. For example:
|
||||
Scalar variables are those containing an <type>integer</type>,
|
||||
<type>float</type>, <type>string</type> or <type>boolean</type>.
|
||||
For example:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<!-- TODO: better example, this one can be quite misleading for unexperienced
|
||||
programmers -->
|
||||
function show_var($var) {
|
||||
if (is_scalar($var))
|
||||
echo $var;
|
||||
|
@ -747,7 +751,7 @@ show_var($proteins)
|
|||
</para>
|
||||
<note>
|
||||
<para>
|
||||
<function>is_scalar</function> does not consider resource
|
||||
<function>is_scalar</function> does not consider <type>resource</type>
|
||||
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)
|
|||
</note>
|
||||
<note>
|
||||
<para>
|
||||
This function was added to the CVS code after the release of PHP
|
||||
4.0.4pl1
|
||||
Since 4.0.5
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
|
@ -790,7 +793,7 @@ show_var($proteins)
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
Returns true if <parameter>var</parameter> is a string,
|
||||
Returns true if <parameter>var</parameter> is a <type>string</type>,
|
||||
false otherwise.
|
||||
</para>
|
||||
<para>
|
||||
|
@ -867,10 +870,11 @@ print isset ($foo); // FALSE
|
|||
</funcsynopsis>
|
||||
<simpara>
|
||||
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 <type>string</type>,
|
||||
<type>integer</type> or <type>double</type>, the value itself will be
|
||||
printed. If given an <type>array</type>,
|
||||
values will be presented in a format that shows keys and
|
||||
elements. Similar notation is used for objects.
|
||||
elements. Similar notation is used for <type>object</type>s.
|
||||
</simpara>
|
||||
<simpara>
|
||||
Remember that <function>print_r</function> will move the array
|
||||
|
@ -894,9 +898,11 @@ print_r ($a);
|
|||
</para>
|
||||
<warning>
|
||||
<para>
|
||||
This function will continue forever if given an array or object
|
||||
This function will continue forever if given an <type>array</type>
|
||||
or <type>object</type>
|
||||
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 <type>array</type> or <type>object</type> on a deeper
|
||||
level that does so.
|
||||
This is especially true for <literal>print_r($GLOBALS)</literal>,
|
||||
as <literal>$GLOBALS</literal> is itself a global variable and
|
||||
contains a reference to itself as such.
|
||||
|
@ -932,10 +938,23 @@ print_r ($a);
|
|||
<simpara>
|
||||
To make the serialized string into a PHP value again, use
|
||||
<function>unserialize</function>. <function>serialize</function>
|
||||
handles the types <type>integer</type>, <type>double</type>,
|
||||
<type>string</type>, <type>array</type> (multidimensional) and
|
||||
<type>object</type>.
|
||||
handles all types, except the <type>resource</type>-type.
|
||||
You can even <function>serialize</function> arrays that contain
|
||||
references to itself. References inside the array/object you
|
||||
are <function>serialize</function>ing will also be stored.
|
||||
</simpara>
|
||||
<!-- TODO
|
||||
in 4.0.4pl1 this didn't work properly, however, there
|
||||
been some fixes. I don't know whether this all
|
||||
works correctly now, and if so, whether it is since 405
|
||||
or 406
|
||||
<note>
|
||||
<simpara>
|
||||
This didn't work correctly until 4.0.?
|
||||
</simpara>
|
||||
</note>
|
||||
</simpara>
|
||||
-->
|
||||
<note>
|
||||
<para>
|
||||
In PHP 3, object properties will be serialized, but methods are
|
||||
|
@ -1041,7 +1060,9 @@ settype($bar, "string"); // $bar is now "1" (string)
|
|||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<simpara>
|
||||
Returns the string value of <parameter>var</parameter>.
|
||||
Returns the <type>string</type> value of <parameter>var</parameter>.
|
||||
See the documentation on <type>string</type> for more information
|
||||
on converting to string.
|
||||
</simpara>
|
||||
<simpara>
|
||||
<parameter>var</parameter> may be any scalar type. You cannot use
|
||||
|
|
Loading…
Reference in a new issue