cvs: phpdoc /en/reference/funchand/functions register-shutdown-function.xml /en/reference/info/functions get-magic-quotes-runtime.xml
set-magic-quotes-runtime.xml zend-thread-id.xml /en/reference/math/functions is-nan.xml /en/reference/misc/functions halt-compiler.xml
ignore-user-abort.xml /en/reference/network/functions define-syslog-variables.xml syslog.xml

From: Date: Tue, 14 Oct 2008 03:07:20 +0000
Subject: cvs: phpdoc /en/reference/funchand/functions register-shutdown-function.xml /en/reference/info/functions get-magic-quotes-runtime.xml
set-magic-quotes-runtime.xml zend-thread-id.xml /en/reference/math/functions is-nan.xml /en/reference/misc/functions halt-compiler.xml
ignore-user-abort.xml /en/reference/network/functions define-syslog-variables.xml syslog.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-2229@lists.php.net to get a copy of this message
kalle Tue Oct 14 03:07:20 2008 UTC Modified files: /phpdoc/en/reference/funchand/functions register-shutdown-function.xml /phpdoc/en/reference/info/functions get-magic-quotes-runtime.xml set-magic-quotes-runtime.xml zend-thread-id.xml /phpdoc/en/reference/math/functions is-nan.xml /phpdoc/en/reference/misc/functions halt-compiler.xml ignore-user-abort.xml /phpdoc/en/reference/network/functions define-syslog-variables.xml syslog.xml Log: * 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

http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/funchand/functions/register-shutdown-function.xml?r1=1.16&r2=1.17&diff_format=u Index: phpdoc/en/reference/funchand/functions/register-shutdown-function.xml diff -u phpdoc/en/reference/funchand/functions/register-shutdown-function.xml:1.16 phpdoc/en/reference/funchand/functions/register-shutdown-function.xml:1.17 --- phpdoc/en/reference/funchand/functions/register-shutdown-function.xml:1.16 Wed Jun 20 22:24:30 2007 +++ phpdoc/en/reference/funchand/functions/register-shutdown-function.xml Tue Oct 14 03:07:19 2008 @@ -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> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/info/functions/get-magic-quotes-runtime.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/info/functions/get-magic-quotes-runtime.xml diff -u phpdoc/en/reference/info/functions/get-magic-quotes-runtime.xml:1.6 phpdoc/en/reference/info/functions/get-magic-quotes-runtime.xml:1.7 --- phpdoc/en/reference/info/functions/get-magic-quotes-runtime.xml:1.6 Wed Jun 20 22:24:47 2007 +++ phpdoc/en/reference/info/functions/get-magic-quotes-runtime.xml Tue Oct 14 03:07:20 2008 @@ -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> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/info/functions/set-magic-quotes-runtime.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/info/functions/set-magic-quotes-runtime.xml diff -u phpdoc/en/reference/info/functions/set-magic-quotes-runtime.xml:1.6 phpdoc/en/reference/info/functions/set-magic-quotes-runtime.xml:1.7 --- phpdoc/en/reference/info/functions/set-magic-quotes-runtime.xml:1.6 Wed Jun 20 22:24:48 2007 +++ phpdoc/en/reference/info/functions/set-magic-quotes-runtime.xml Tue Oct 14 03:07:20 2008 @@ -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> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/info/functions/zend-thread-id.xml?r1=1.3&r2=1.4&diff_format=u Index: phpdoc/en/reference/info/functions/zend-thread-id.xml diff -u phpdoc/en/reference/info/functions/zend-thread-id.xml:1.3 phpdoc/en/reference/info/functions/zend-thread-id.xml:1.4 --- phpdoc/en/reference/info/functions/zend-thread-id.xml:1.3 Mon Aug 11 15:22:01 2008 +++ phpdoc/en/reference/info/functions/zend-thread-id.xml Tue Oct 14 03:07:20 2008 @@ -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> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/math/functions/is-nan.xml?r1=1.8&r2=1.9&diff_format=u Index: phpdoc/en/reference/math/functions/is-nan.xml diff -u phpdoc/en/reference/math/functions/is-nan.xml:1.8 phpdoc/en/reference/math/functions/is-nan.xml:1.9 --- phpdoc/en/reference/math/functions/is-nan.xml:1.8 Wed Jun 20 22:24:51 2007 +++ phpdoc/en/reference/math/functions/is-nan.xml Tue Oct 14 03:07:20 2008 @@ -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 http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/misc/functions/halt-compiler.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/misc/functions/halt-compiler.xml diff -u phpdoc/en/reference/misc/functions/halt-compiler.xml:1.6 phpdoc/en/reference/misc/functions/halt-compiler.xml:1.7 --- phpdoc/en/reference/misc/functions/halt-compiler.xml:1.6 Wed Jun 20 22:24:57 2007 +++ phpdoc/en/reference/misc/functions/halt-compiler.xml Tue Oct 14 03:07:20 2008 @@ -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 @@ 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> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/misc/functions/ignore-user-abort.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/misc/functions/ignore-user-abort.xml diff -u phpdoc/en/reference/misc/functions/ignore-user-abort.xml:1.7 phpdoc/en/reference/misc/functions/ignore-user-abort.xml:1.8 --- phpdoc/en/reference/misc/functions/ignore-user-abort.xml:1.7 Tue Oct 2 18:42:57 2007 +++ phpdoc/en/reference/misc/functions/ignore-user-abort.xml Tue Oct 14 03:07:20 2008 @@ -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> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/network/functions/define-syslog-variables.xml?r1=1.5&r2=1.6&diff_format=u Index: phpdoc/en/reference/network/functions/define-syslog-variables.xml diff -u phpdoc/en/reference/network/functions/define-syslog-variables.xml:1.5 phpdoc/en/reference/network/functions/define-syslog-variables.xml:1.6 --- phpdoc/en/reference/network/functions/define-syslog-variables.xml:1.5 Wed Jun 20 22:25:04 2007 +++ phpdoc/en/reference/network/functions/define-syslog-variables.xml Tue Oct 14 03:07:20 2008 @@ -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> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/network/functions/syslog.xml?r1=1.12&r2=1.13&diff_format=u Index: phpdoc/en/reference/network/functions/syslog.xml diff -u phpdoc/en/reference/network/functions/syslog.xml:1.12 phpdoc/en/reference/network/functions/syslog.xml:1.13 --- phpdoc/en/reference/network/functions/syslog.xml:1.12 Wed Jun 20 22:25:05 2007 +++ phpdoc/en/reference/network/functions/syslog.xml Tue Oct 14 03:07:20 2008 @@ -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
« previous php.doc.cvs (#2229) next »