mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
WS, prepare for new doc style
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@237372 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
ed249509ed
commit
436d3010d7
5 changed files with 401 additions and 402 deletions
|
@ -1,42 +1,42 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.15 $ -->
|
||||
<!-- $Revision: 1.16 $ -->
|
||||
<!-- splitted from ./en/functions/var.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.isset">
|
||||
<refnamediv>
|
||||
<refname>isset</refname>
|
||||
<refpurpose>Determine whether a variable is set</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>bool</type><methodname>isset</methodname>
|
||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
<methodparam choice="opt"><parameter>...</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
|
||||
<simpara>
|
||||
Returns &true; if <parameter>var</parameter> exists; &false; otherwise.
|
||||
</simpara>
|
||||
<para>
|
||||
If a variable has been unset with <function>unset</function>, it will no
|
||||
longer be set. <function>isset</function> will
|
||||
return &false; if testing a variable that has been set to &null;. Also
|
||||
note that a &null; byte (<literal>"\0"</literal>) is not equivalent to
|
||||
the PHP &null; constant.
|
||||
</para>
|
||||
<note>
|
||||
<title>Warning</title>
|
||||
<para>
|
||||
<function>isset</function> only works with variables as passing anything
|
||||
else will result in a parse error. For checking if
|
||||
<link linkend="language.constants">constants</link> are set use the
|
||||
<function>defined</function> function.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<refentry id="function.isset">
|
||||
<refnamediv>
|
||||
<refname>isset</refname>
|
||||
<refpurpose>Determine whether a variable is set</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>bool</type><methodname>isset</methodname>
|
||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
<methodparam choice="opt"><parameter>...</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
|
||||
<simpara>
|
||||
Returns &true; if <parameter>var</parameter> exists; &false; otherwise.
|
||||
</simpara>
|
||||
<para>
|
||||
If a variable has been unset with <function>unset</function>, it will no
|
||||
longer be set. <function>isset</function> will
|
||||
return &false; if testing a variable that has been set to &null;. Also
|
||||
note that a &null; byte (<literal>"\0"</literal>) is not equivalent to
|
||||
the PHP &null; constant.
|
||||
</para>
|
||||
<note>
|
||||
<title>Warning</title>
|
||||
<para>
|
||||
<function>isset</function> only works with variables as passing anything
|
||||
else will result in a parse error. For checking if
|
||||
<link linkend="language.constants">constants</link> are set use the
|
||||
<function>defined</function> function.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
@ -66,13 +66,13 @@ var_dump(isset($foo)); // FALSE
|
|||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
This also work for elements in arrays:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
This also work for elements in arrays:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
|
@ -88,24 +88,24 @@ var_dump(array_key_exists('hello', $a)); // TRUE
|
|||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
||||
¬e.language-construct;
|
||||
|
||||
<simpara>
|
||||
See also <function>empty</function>,
|
||||
<function>unset</function>,
|
||||
<function>defined</function>,
|
||||
<link linkend="types.comparisons">the type comparison tables</link>,
|
||||
<function>array_key_exists</function>,
|
||||
<function>is_null</function>,
|
||||
and the error control
|
||||
<link linkend="language.operators.errorcontrol">@</link> operator.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
||||
¬e.language-construct;
|
||||
|
||||
<simpara>
|
||||
See also <function>empty</function>,
|
||||
<function>unset</function>,
|
||||
<function>defined</function>,
|
||||
<link linkend="types.comparisons">the type comparison tables</link>,
|
||||
<function>array_key_exists</function>,
|
||||
<function>is_null</function>,
|
||||
and the error control
|
||||
<link linkend="language.operators.errorcontrol">@</link> operator.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,44 +1,44 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<!-- $Revision: 1.14 $ -->
|
||||
<!-- splitted from ./en/functions/var.xml, last change in rev 1.5 -->
|
||||
<refentry id="function.print-r">
|
||||
<refnamediv>
|
||||
<refname>print_r</refname>
|
||||
<refpurpose>
|
||||
Prints human-readable information about a variable
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>mixed</type><methodname>print_r</methodname>
|
||||
<methodparam><type>mixed</type><parameter>expression</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>bool</type><parameter>return</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<note>
|
||||
<simpara>
|
||||
The <parameter>return</parameter> parameter was added in PHP 4.3.0
|
||||
</simpara>
|
||||
</note>
|
||||
<simpara>
|
||||
<function>print_r</function> displays information about a variable
|
||||
in a way that's readable by humans. If given a <type>string</type>,
|
||||
<type>integer</type> or <type>float</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 <type>object</type>s.
|
||||
<function>print_r</function>, <function>var_dump</function> and
|
||||
<function>var_export</function> will
|
||||
also show protected and private properties of objects with PHP 5.
|
||||
</simpara>
|
||||
<simpara>
|
||||
Remember that <function>print_r</function> will move the array
|
||||
pointer to the end. Use <function>reset</function> to bring
|
||||
it back to beginning.
|
||||
</simpara>
|
||||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<refentry id="function.print-r">
|
||||
<refnamediv>
|
||||
<refname>print_r</refname>
|
||||
<refpurpose>
|
||||
Prints human-readable information about a variable
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>mixed</type><methodname>print_r</methodname>
|
||||
<methodparam><type>mixed</type><parameter>expression</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>bool</type><parameter>return</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<note>
|
||||
<simpara>
|
||||
The <parameter>return</parameter> parameter was added in PHP 4.3.0
|
||||
</simpara>
|
||||
</note>
|
||||
<simpara>
|
||||
<function>print_r</function> displays information about a variable
|
||||
in a way that's readable by humans. If given a <type>string</type>,
|
||||
<type>integer</type> or <type>float</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 <type>object</type>s.
|
||||
<function>print_r</function>, <function>var_dump</function> and
|
||||
<function>var_export</function> will
|
||||
also show protected and private properties of objects with PHP 5.
|
||||
</simpara>
|
||||
<simpara>
|
||||
Remember that <function>print_r</function> will move the array
|
||||
pointer to the end. Use <function>reset</function> to bring
|
||||
it back to beginning.
|
||||
</simpara>
|
||||
<para>
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<pre>
|
||||
<?php
|
||||
|
@ -47,9 +47,9 @@
|
|||
?>
|
||||
</pre>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<pre>
|
||||
Array
|
||||
|
@ -65,53 +65,53 @@ Array
|
|||
)
|
||||
</pre>
|
||||
]]>
|
||||
</screen>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
If you would like to capture the output of <function>print_r</function>,
|
||||
use the <parameter>return</parameter> parameter. If this parameter is set
|
||||
to &true;, <function>print_r</function> will return its output, instead of
|
||||
printing it (which it does by default).
|
||||
</para>
|
||||
¬e.uses-ob;
|
||||
<para>
|
||||
<example>
|
||||
<title><parameter>return</parameter> parameter example</title>
|
||||
<programlisting role="php">
|
||||
</screen>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
If you would like to capture the output of <function>print_r</function>,
|
||||
use the <parameter>return</parameter> parameter. If this parameter is set
|
||||
to &true;, <function>print_r</function> will return its output, instead of
|
||||
printing it (which it does by default).
|
||||
</para>
|
||||
¬e.uses-ob;
|
||||
<para>
|
||||
<example>
|
||||
<title><parameter>return</parameter> parameter example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$b = array ('m' => 'monkey', 'foo' => 'bar', 'x' => array ('x', 'y', 'z'));
|
||||
$results = print_r($b, true); //$results now contains output from print_r
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<note>
|
||||
<simpara>
|
||||
If you need to capture the output of <function>print_r</function> with a
|
||||
version of PHP prior to 4.3.0, use the <link linkend="ref.outcontrol">
|
||||
output-control functions</link>.
|
||||
</simpara>
|
||||
</note>
|
||||
<note>
|
||||
<simpara>
|
||||
Prior to PHP 4.0.4, <function>print_r</function> will continue forever
|
||||
if given an <type>array</type> or <type>object</type> that
|
||||
contains a direct or indirect reference to itself. An example
|
||||
is <literal>print_r($GLOBALS)</literal> because
|
||||
<literal>$GLOBALS</literal> is itself a global variable that
|
||||
contains a reference to itself.
|
||||
</simpara>
|
||||
</note>
|
||||
<simpara>
|
||||
See also <function>ob_start</function>,
|
||||
<function>var_dump</function> and
|
||||
<function>var_export</function>.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<note>
|
||||
<simpara>
|
||||
If you need to capture the output of <function>print_r</function> with a
|
||||
version of PHP prior to 4.3.0, use the <link linkend="ref.outcontrol">
|
||||
output-control functions</link>.
|
||||
</simpara>
|
||||
</note>
|
||||
<note>
|
||||
<simpara>
|
||||
Prior to PHP 4.0.4, <function>print_r</function> will continue forever
|
||||
if given an <type>array</type> or <type>object</type> that
|
||||
contains a direct or indirect reference to itself. An example
|
||||
is <literal>print_r($GLOBALS)</literal> because
|
||||
<literal>$GLOBALS</literal> is itself a global variable that
|
||||
contains a reference to itself.
|
||||
</simpara>
|
||||
</note>
|
||||
<simpara>
|
||||
See also <function>ob_start</function>,
|
||||
<function>var_dump</function> and
|
||||
<function>var_export</function>.
|
||||
</simpara>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,66 +1,66 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.11 $ -->
|
||||
<!-- $Revision: 1.12 $ -->
|
||||
<!-- splitted from ./en/functions/var.xml, last change in rev 1.28 -->
|
||||
<refentry id="function.serialize">
|
||||
<refnamediv>
|
||||
<refname>serialize</refname>
|
||||
<refpurpose>
|
||||
Generates a storable representation of a value
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>string</type><methodname>serialize</methodname>
|
||||
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<simpara>
|
||||
<function>serialize</function> returns a string containing a
|
||||
byte-stream representation of <parameter>value</parameter> that
|
||||
can be stored anywhere.
|
||||
</simpara>
|
||||
<simpara>
|
||||
This is useful for storing or passing PHP values around without
|
||||
losing their type and structure.
|
||||
</simpara>
|
||||
<refentry id="function.serialize">
|
||||
<refnamediv>
|
||||
<refname>serialize</refname>
|
||||
<refpurpose>
|
||||
Generates a storable representation of a value
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>string</type><methodname>serialize</methodname>
|
||||
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<simpara>
|
||||
<function>serialize</function> returns a string containing a
|
||||
byte-stream representation of <parameter>value</parameter> that
|
||||
can be stored anywhere.
|
||||
</simpara>
|
||||
<simpara>
|
||||
This is useful for storing or passing PHP values around without
|
||||
losing their type and structure.
|
||||
</simpara>
|
||||
<simpara>
|
||||
To make the serialized string into a PHP value again, use
|
||||
<function>unserialize</function>. <function>serialize</function>
|
||||
handles all types, except the <type>resource</type>-type.
|
||||
You can even <function>serialize</function> arrays that contain
|
||||
references to itself. Circular references inside the array/object you
|
||||
are <function>serialize</function>ing will also be stored. Any other
|
||||
reference will be lost.
|
||||
</simpara>
|
||||
<simpara>
|
||||
When serializing objects, PHP will attempt to call the member function
|
||||
<function>__sleep</function> prior to serialization. This is to allow the
|
||||
object to do any last minute clean-up, etc. prior to being serialized.
|
||||
Likewise, when the object is restored using <function>unserialize</function>
|
||||
the <function>__wakeup</function> member function is called.
|
||||
</simpara>
|
||||
<note>
|
||||
<simpara>
|
||||
To make the serialized string into a PHP value again, use
|
||||
<function>unserialize</function>. <function>serialize</function>
|
||||
handles all types, except the <type>resource</type>-type.
|
||||
You can even <function>serialize</function> arrays that contain
|
||||
references to itself. Circular references inside the array/object you
|
||||
are <function>serialize</function>ing will also be stored. Any other
|
||||
reference will be lost.
|
||||
This didn't work correctly until 4.0.7.
|
||||
</simpara>
|
||||
<simpara>
|
||||
When serializing objects, PHP will attempt to call the member function
|
||||
<function>__sleep</function> prior to serialization. This is to allow the
|
||||
object to do any last minute clean-up, etc. prior to being serialized.
|
||||
Likewise, when the object is restored using <function>unserialize</function>
|
||||
the <function>__wakeup</function> member function is called.
|
||||
</simpara>
|
||||
<note>
|
||||
<simpara>
|
||||
This didn't work correctly until 4.0.7.
|
||||
</simpara>
|
||||
</note>
|
||||
<note>
|
||||
<para>
|
||||
In PHP 3, object properties will be serialized, but methods are
|
||||
lost. That limitation was removed in PHP 4 as both properties
|
||||
and methods are now restored. Please see the <link
|
||||
linkend="language.oop.serialization">Serializing Objects</link>
|
||||
section of <link linkend="language.oop">Classes and
|
||||
Objects</link> for more information.
|
||||
</para>
|
||||
<para>
|
||||
It is not possible to serialize PHP built-in objects.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>serialize</function> example</title>
|
||||
<programlisting role="php">
|
||||
</note>
|
||||
<note>
|
||||
<para>
|
||||
In PHP 3, object properties will be serialized, but methods are
|
||||
lost. That limitation was removed in PHP 4 as both properties
|
||||
and methods are now restored. Please see the <link
|
||||
linkend="language.oop.serialization">Serializing Objects</link>
|
||||
section of <link linkend="language.oop">Classes and
|
||||
Objects</link> for more information.
|
||||
</para>
|
||||
<para>
|
||||
It is not possible to serialize PHP built-in objects.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>serialize</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// $session_data contains a multi-dimensional array with session
|
||||
|
@ -80,14 +80,14 @@ if (!odbc_execute($stmt, &$sqldata)) {
|
|||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See Also: <function>unserialize</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See Also: <function>unserialize</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,58 +1,58 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.19 $ -->
|
||||
<!-- $Revision: 1.20 $ -->
|
||||
<!-- splitted from ./en/functions/var.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.unserialize">
|
||||
<refnamediv>
|
||||
<refname>unserialize</refname>
|
||||
<refpurpose>
|
||||
Creates a PHP value from a stored representation
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>mixed</type><methodname>unserialize</methodname>
|
||||
<methodparam><type>string</type><parameter>str</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<simpara>
|
||||
<function>unserialize</function> takes a single serialized
|
||||
variable (see <function>serialize</function>) and converts it
|
||||
back into a PHP value. The converted value is returned, and can
|
||||
be a <type>boolean</type>, <type>integer</type>, <type>float</type>,
|
||||
<type>string</type>, <type>array</type> or <type>object</type>.
|
||||
In case the passed string is not unserializeable, &false; is returned and
|
||||
<literal>E_NOTICE</literal> is issued.
|
||||
</simpara>
|
||||
<warning>
|
||||
<para>
|
||||
&false; is returned both in the case of an error and if unserializing
|
||||
the serialized &false; value. It is possible to catch this special case by
|
||||
comparing <parameter>str</parameter> with
|
||||
<literal>serialize(false)</literal> or by catching the issued
|
||||
<literal>E_NOTICE</literal>.
|
||||
</para>
|
||||
</warning>
|
||||
<note>
|
||||
<title>unserialize_callback_func directive</title>
|
||||
<para>
|
||||
It's possible to set a callback-function which will be called,
|
||||
if an undefined class should be instantiated during unserializing.
|
||||
(to prevent getting an incomplete <type>object</type> "__PHP_Incomplete_Class".)
|
||||
Use your &php.ini;, <function>ini_set</function> or &htaccess;
|
||||
to define 'unserialize_callback_func'. Everytime an undefined class
|
||||
should be instantiated, it'll be called. To disable this feature just
|
||||
empty this setting. Also note that the directive
|
||||
unserialize_callback_func directive became
|
||||
available in PHP 4.2.0.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
If the variable being unserialized is an object, after successfully
|
||||
reconstructing the object PHP will automatically attempt to call the
|
||||
<function>__wakeup</function> member function (if it exists).
|
||||
<example>
|
||||
<title>unserialize_callback_func example</title>
|
||||
<programlisting role="php">
|
||||
<refentry id="function.unserialize">
|
||||
<refnamediv>
|
||||
<refname>unserialize</refname>
|
||||
<refpurpose>
|
||||
Creates a PHP value from a stored representation
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>mixed</type><methodname>unserialize</methodname>
|
||||
<methodparam><type>string</type><parameter>str</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<simpara>
|
||||
<function>unserialize</function> takes a single serialized
|
||||
variable (see <function>serialize</function>) and converts it
|
||||
back into a PHP value. The converted value is returned, and can
|
||||
be a <type>boolean</type>, <type>integer</type>, <type>float</type>,
|
||||
<type>string</type>, <type>array</type> or <type>object</type>.
|
||||
In case the passed string is not unserializeable, &false; is returned and
|
||||
<literal>E_NOTICE</literal> is issued.
|
||||
</simpara>
|
||||
<warning>
|
||||
<para>
|
||||
&false; is returned both in the case of an error and if unserializing
|
||||
the serialized &false; value. It is possible to catch this special case by
|
||||
comparing <parameter>str</parameter> with
|
||||
<literal>serialize(false)</literal> or by catching the issued
|
||||
<literal>E_NOTICE</literal>.
|
||||
</para>
|
||||
</warning>
|
||||
<note>
|
||||
<title>unserialize_callback_func directive</title>
|
||||
<para>
|
||||
It's possible to set a callback-function which will be called,
|
||||
if an undefined class should be instantiated during unserializing.
|
||||
(to prevent getting an incomplete <type>object</type> "__PHP_Incomplete_Class".)
|
||||
Use your &php.ini;, <function>ini_set</function> or &htaccess;
|
||||
to define 'unserialize_callback_func'. Everytime an undefined class
|
||||
should be instantiated, it'll be called. To disable this feature just
|
||||
empty this setting. Also note that the directive
|
||||
unserialize_callback_func directive became
|
||||
available in PHP 4.2.0.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
If the variable being unserialized is an object, after successfully
|
||||
reconstructing the object PHP will automatically attempt to call the
|
||||
<function>__wakeup</function> member function (if it exists).
|
||||
<example>
|
||||
<title>unserialize_callback_func example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$serialized_object='O:1:"a":1:{s:5:"value";s:3:"100";}';
|
||||
|
@ -67,23 +67,23 @@ function mycallback($classname)
|
|||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
In PHP 3, methods are not preserved when unserializing a
|
||||
serialized object. That limitation was removed in PHP 4 as both
|
||||
properties and methods are now restored. Please see the <link
|
||||
linkend="language.oop.serialization">Serializing Objects</link>
|
||||
section of <link linkend="language.oop">Classes and
|
||||
Objects</link> or more information.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>unserialize</function> example</title>
|
||||
<programlisting role="php">
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
In PHP 3, methods are not preserved when unserializing a
|
||||
serialized object. That limitation was removed in PHP 4 as both
|
||||
properties and methods are now restored. Please see the <link
|
||||
linkend="language.oop.serialization">Serializing Objects</link>
|
||||
section of <link linkend="language.oop">Classes and
|
||||
Objects</link> or more information.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>unserialize</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Here, we use unserialize() to load session data to the
|
||||
|
@ -106,14 +106,14 @@ if (!odbc_execute($stmt, &$sqldata) || !odbc_fetch_into($stmt, &$tmp)) {
|
|||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <function>serialize</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <function>serialize</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
|
@ -1,33 +1,32 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.14 $ -->
|
||||
<!-- $Revision: 1.15 $ -->
|
||||
<!-- splitted from ./en/functions/var.xml, last change in rev 1.2 -->
|
||||
<refentry id="function.unset">
|
||||
<refnamediv>
|
||||
<refname>unset</refname>
|
||||
<refpurpose>Unset a given variable</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>unset</methodname>
|
||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
<function>unset</function> destroys the specified variables. Note
|
||||
that in PHP 3, <function>unset</function> will always return &true;
|
||||
(actually, the integer value 1). In PHP 4, however,
|
||||
<function>unset</function> is no longer a true function: it is
|
||||
now a statement. As such no value is returned, and attempting to
|
||||
take the value of <function>unset</function> results in a parse
|
||||
error.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>unset</function> example</title>
|
||||
<programlisting role="php">
|
||||
<refentry id="function.unset">
|
||||
<refnamediv>
|
||||
<refname>unset</refname>
|
||||
<refpurpose>Unset a given variable</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>unset</methodname>
|
||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>...</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
<function>unset</function> destroys the specified variables. Note
|
||||
that in PHP 3, <function>unset</function> will always return &true;
|
||||
(actually, the integer value 1). In PHP 4, however,
|
||||
<function>unset</function> is no longer a true function: it is
|
||||
now a statement. As such no value is returned, and attempting to
|
||||
take the value of <function>unset</function> results in a parse
|
||||
error.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>unset</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// destroy a single variable
|
||||
|
@ -40,26 +39,26 @@ unset($bar['quux']);
|
|||
unset($foo1, $foo2, $foo3);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
It is possible to unset even object properties visible in current context.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
The behavior of <function>unset</function> inside of a function
|
||||
can vary depending on what type of variable you are attempting to
|
||||
destroy.
|
||||
</para>
|
||||
<para>
|
||||
If a globalized variable is <function>unset</function> inside of
|
||||
a function, only the local variable is destroyed. The variable
|
||||
in the calling environment will retain the same value as before
|
||||
<function>unset</function> was called.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
It is possible to unset even object properties visible in current context.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
The behavior of <function>unset</function> inside of a function
|
||||
can vary depending on what type of variable you are attempting to
|
||||
destroy.
|
||||
</para>
|
||||
<para>
|
||||
If a globalized variable is <function>unset</function> inside of
|
||||
a function, only the local variable is destroyed. The variable
|
||||
in the calling environment will retain the same value as before
|
||||
<function>unset</function> was called.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function destroy_foo()
|
||||
|
@ -73,25 +72,25 @@ destroy_foo();
|
|||
echo $foo;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
&example.outputs;
|
||||
<para>
|
||||
<informalexample>
|
||||
<screen>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
&example.outputs;
|
||||
<para>
|
||||
<informalexample>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bar
|
||||
]]>
|
||||
</screen>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
If you would like to <function>unset</function> a global variable
|
||||
inside of a function, you can use
|
||||
the <varname>$GLOBALS</varname> array to do so:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
</screen>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
If you would like to <function>unset</function> a global variable
|
||||
inside of a function, you can use
|
||||
the <varname>$GLOBALS</varname> array to do so:
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function foo()
|
||||
|
@ -103,17 +102,17 @@ $bar = "something";
|
|||
foo();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
If a variable that is PASSED BY REFERENCE is
|
||||
<function>unset</function> inside of a function, only the local
|
||||
variable is destroyed. The variable in the calling environment
|
||||
will retain the same value as before <function>unset</function>
|
||||
was called.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
If a variable that is PASSED BY REFERENCE is
|
||||
<function>unset</function> inside of a function, only the local
|
||||
variable is destroyed. The variable in the calling environment
|
||||
will retain the same value as before <function>unset</function>
|
||||
was called.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function foo(&$bar)
|
||||
|
@ -129,27 +128,27 @@ foo($bar);
|
|||
echo "$bar\n";
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
&example.outputs;
|
||||
<para>
|
||||
<informalexample>
|
||||
<screen>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
&example.outputs;
|
||||
<para>
|
||||
<informalexample>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
something
|
||||
something
|
||||
]]>
|
||||
</screen>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
If a static variable is <function>unset</function> inside of a
|
||||
function, <function>unset</function> destroys the variable only in the
|
||||
context of the rest of a function. Following calls will restore the
|
||||
previous value of a variable.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
</screen>
|
||||
</informalexample>
|
||||
</para>
|
||||
<para>
|
||||
If a static variable is <function>unset</function> inside of a
|
||||
function, <function>unset</function> destroys the variable only in the
|
||||
context of the rest of a function. Following calls will restore the
|
||||
previous value of a variable.
|
||||
<informalexample>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
function foo()
|
||||
|
@ -167,31 +166,31 @@ foo();
|
|||
foo();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
&example.outputs;
|
||||
<para>
|
||||
<informalexample>
|
||||
<screen>
|
||||
</programlisting>
|
||||
</informalexample>
|
||||
</para>
|
||||
&example.outputs;
|
||||
<para>
|
||||
<informalexample>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Before unset: 1, after unset: 23
|
||||
Before unset: 2, after unset: 23
|
||||
Before unset: 3, after unset: 23
|
||||
]]>
|
||||
</screen>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
||||
¬e.language-construct;
|
||||
|
||||
<para>
|
||||
See also <function>isset</function>,
|
||||
<function>empty</function>, and
|
||||
<function>array_splice</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
</screen>
|
||||
</informalexample>
|
||||
</para>
|
||||
|
||||
¬e.language-construct;
|
||||
|
||||
<para>
|
||||
See also <function>isset</function>,
|
||||
<function>empty</function>, and
|
||||
<function>array_splice</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
|
Loading…
Reference in a new issue