mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
* Added examples for:
* register_shutdown_function * get_magic_quotes_runtime * set_magic_quotes_runtime * zend_thread_id * is_nan * ignore_user_abort * define_syslog_variables * Fix examples on syslog and __halt_compiler functions git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@267310 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
f8c1327682
commit
193329c660
9 changed files with 251 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.16 $ -->
|
||||
<!-- $Revision: 1.17 $ -->
|
||||
<refentry xml:id="function.register-shutdown-function" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>register_shutdown_function</refname>
|
||||
|
@ -84,6 +84,54 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>register_shutdown_function</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Find out whenever we're on PHP4 or not
|
||||
define('IS_PHP4', PHP_VERSION == 4);
|
||||
|
||||
// Declare our class
|
||||
class Destructor
|
||||
{
|
||||
// PHP4 style constructor, point it
|
||||
// to use the PHP5+ model
|
||||
function Destructor()
|
||||
{
|
||||
$this->__construct();
|
||||
}
|
||||
|
||||
// PHP5 style constructor, register
|
||||
// the shutdown handler
|
||||
function __construct()
|
||||
{
|
||||
if(IS_PHP4)
|
||||
{
|
||||
register_shutdown_function(Array(&$this, '__destruct'));
|
||||
}
|
||||
|
||||
echo 'Constructed', PHP_EOL;
|
||||
}
|
||||
|
||||
// Destructor
|
||||
function __destruct()
|
||||
{
|
||||
echo 'Destructed', PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
new Destructor;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="notes">
|
||||
&reftitle.notes;
|
||||
<note>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<refentry xml:id="function.get-magic-quotes-runtime" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>get_magic_quotes_runtime</refname>
|
||||
|
@ -25,6 +25,27 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>get_magic_quotes_runtime</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Check if magic_quotes_runtime is active
|
||||
if(get_magic_quotes_runtime())
|
||||
{
|
||||
// Deactive
|
||||
set_magic_quotes_runtime(false);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<refentry xml:id="function.set-magic-quotes-runtime" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>set_magic_quotes_runtime</refname>
|
||||
|
@ -41,6 +41,48 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>set_magic_quotes_runtime</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Create a temporary file pointer
|
||||
$fp = tmpfile();
|
||||
|
||||
// Write some data to the pointer
|
||||
fwrite($fp, '\'PHP\' is a Recursive acronym');
|
||||
|
||||
// Without magic_quotes_runtime
|
||||
rewind($fp);
|
||||
set_magic_quotes_runtime(false);
|
||||
|
||||
echo 'Without magic_quotes_runtime: ' . fread($fp, 64), PHP_EOL;
|
||||
|
||||
// With magic_quotes_runtime
|
||||
rewind($fp);
|
||||
set_magic_quotes_runtime(true);
|
||||
|
||||
echo 'With magic_quotes_runtime: ' . fread($fp, 64), PHP_EOL;
|
||||
|
||||
// Clean up
|
||||
fclose($fp);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Without magic_quotes_runtime: 'PHP' is a Recursive acronym
|
||||
With magic_quotes_runtime: \'PHP\' is a Recursive acronym
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<refentry xml:id="function.zend-thread-id">
|
||||
<refnamediv>
|
||||
<refname>zend_thread_id</refname>
|
||||
|
@ -24,6 +24,30 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>zend_thread_id</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$thread_id = zend_thread_id();
|
||||
|
||||
echo 'Current thread id is: ' . $thread_id;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Current thread id is: 7864
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="notes">
|
||||
&reftitle.notes;
|
||||
<note>
|
||||
|
|
|
@ -1,21 +1,23 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<!-- $Revision: 1.9 $ -->
|
||||
<refentry xml:id='function.is-nan' xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>is_nan</refname>
|
||||
<refpurpose>Finds whether a value is not a number</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>bool</type><methodname>is_nan</methodname>
|
||||
<methodparam><type>float</type><parameter>val</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<methodsynopsis>
|
||||
<type>bool</type><methodname>is_nan</methodname>
|
||||
<methodparam><type>float</type><parameter>val</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Checks whether <parameter>val</parameter> is 'not a number',
|
||||
like the result of <literal>acos(1.01)</literal>.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<para>
|
||||
|
@ -31,6 +33,7 @@
|
|||
</variablelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
|
@ -38,6 +41,34 @@
|
|||
else &false;.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>is_nan</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Invalid calculation, will return a
|
||||
// NaN value
|
||||
$nan = acos(8);
|
||||
|
||||
var_dump($nan, is_nan($nan));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
float(NAN)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
|
@ -47,6 +78,7 @@
|
|||
</simplelist>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<refentry xml:id="function.halt-compiler" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>__halt_compiler</refname>
|
||||
|
@ -51,7 +51,7 @@ fseek($fp, __COMPILER_HALT_OFFSET__);
|
|||
var_dump(stream_get_contents($fp));
|
||||
|
||||
// the end of the script execution
|
||||
__halt_compiler();the installation data (eg. tar, gz, PHP, etc.)
|
||||
__halt_compiler(); // the installation data (eg. tar, gz, PHP, etc.)
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<refentry xml:id="function.ignore-user-abort" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>ignore_user_abort</refname>
|
||||
|
@ -39,6 +39,50 @@
|
|||
Returns the previous setting, as a boolean.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title>A <function>ignore_user_abort</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Ignore user aborts and allow the script
|
||||
// to run forever
|
||||
ignore_user_abort();
|
||||
set_time_limit(0);
|
||||
|
||||
echo 'Testing connection handling in PHP';
|
||||
|
||||
// Run a pointless loop that sometime
|
||||
// hopefully will make us click away from
|
||||
// page or click the "Stop" button.
|
||||
while(1)
|
||||
{
|
||||
// Did the connection fail?
|
||||
if(connection_status() != CONNECTION_NORMAL)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Sleep for 10 seconds
|
||||
sleep(10);
|
||||
}
|
||||
|
||||
// If this is reached, then the 'break'
|
||||
// was triggered from inside the while loop
|
||||
|
||||
// So here we can log, or perform any other tasks
|
||||
// we need without actually being dependent on the
|
||||
// browser.
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="notes">
|
||||
&reftitle.notes;
|
||||
<para>
|
||||
|
@ -48,6 +92,7 @@
|
|||
<function>flush</function>.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<refentry xml:id="function.define-syslog-variables" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>define_syslog_variables</refname>
|
||||
|
@ -24,6 +24,31 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>define_syslog_variables</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Check if syslog variables already is defined
|
||||
if(!get_cfg_var('define_syslog_variables'))
|
||||
{
|
||||
define_syslog_variables();
|
||||
}
|
||||
|
||||
// Open the log
|
||||
openlog('', $LOG_ODELAY, $LOG_MAIL | $LOG_USER);
|
||||
|
||||
// Continue script ...
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.12 $ -->
|
||||
<!-- $Revision: 1.13 $ -->
|
||||
<refentry xml:id="function.syslog" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>syslog</refname>
|
||||
|
@ -115,7 +115,6 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
define_syslog_variables();
|
||||
// open syslog, include the process ID and also send
|
||||
// the log to standard error, and use a user defined
|
||||
// logging mechanism
|
||||
|
|
Loading…
Reference in a new issue