mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
* Added new examples for
* assert_options * get_current_user * ini_restore * sys_get_temp_dir * sha1_file git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@267550 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
e4f61b566b
commit
cf577d2adf
6 changed files with 167 additions and 6 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- $Revision: 1.7 $ -->
|
||||
<refentry xml:id="function.assert-options" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>assert_options</refname>
|
||||
|
@ -97,6 +97,55 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>assert_options</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// This is our function to handle
|
||||
// assert failures
|
||||
function assert_failure()
|
||||
{
|
||||
echo 'Assert failed';
|
||||
}
|
||||
|
||||
// This is our test function
|
||||
function test_assert($parameter)
|
||||
{
|
||||
assert(is_bool($parameter));
|
||||
}
|
||||
|
||||
// Set our assert options
|
||||
assert_options(ASSERT_ACTIVE, true);
|
||||
assert_options(ASSERT_BAIL, true);
|
||||
assert_options(ASSERT_WARNING, false);
|
||||
assert_options(ASSERT_CALLBACK, 'assert_failure');
|
||||
|
||||
// Make an assert that would fail
|
||||
test_assert(1);
|
||||
|
||||
// This is never reached due to ASSERT_BAIL
|
||||
// being true
|
||||
echo 'Never reached';
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><function>assert</function></member>
|
||||
</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.11 $ -->
|
||||
<!-- $Revision: 1.12 $ -->
|
||||
<refentry xml:id="function.assert" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>assert</refname>
|
||||
|
@ -128,6 +128,15 @@ assert('mysql_query("")');
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
<simplelist>
|
||||
<member><function>assert_options</function></member>
|
||||
</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.7 $ -->
|
||||
<!-- $Revision: 1.8 $ -->
|
||||
<refentry xml:id="function.get-current-user" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>get_current_user</refname>
|
||||
|
@ -24,6 +24,28 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>get_current_user</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
echo 'Current script owner: ' . get_current_user();
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Current script owner: SYSTEM
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.10 $ -->
|
||||
<!-- $Revision: 1.11 $ -->
|
||||
<refentry xml:id="function.ini-restore" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>ini_restore</refname>
|
||||
|
@ -40,6 +40,38 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>ini_restore</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$setting = 'y2k_compliance';
|
||||
|
||||
echo 'Current value for \'' . $setting . '\': ' . ini_get($setting), PHP_EOL;
|
||||
|
||||
ini_set($setting, ini_get($setting) ? 0 : 1);
|
||||
echo 'New value for \'' . $setting . '\': ' . ini_get($setting), PHP_EOL;
|
||||
|
||||
ini_restore($setting);
|
||||
echo 'Original value for \'' . $setting . '\': ' . ini_get($setting), PHP_EOL;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Current value for 'y2k_compliance': 1
|
||||
New value for 'y2k_compliance': 0
|
||||
Original value for 'y2k_compliance': 1
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="seealso">
|
||||
&reftitle.seealso;
|
||||
<para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<refentry xml:id="function.sys-get-temp-dir" xmlns="http://docbook.org/ns/docbook">
|
||||
<refnamediv>
|
||||
<refname>sys_get_temp_dir</refname>
|
||||
|
@ -25,6 +25,32 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>sys_get_temp_dir</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Create a temporary file in the temporary
|
||||
// files directory using sys_get_temp_dir()
|
||||
$temp_file = tempnam(sys_get_temp_dir(), 'Tux');
|
||||
|
||||
echo $temp_file;
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
C:\Windows\Temp\TuxA318.tmp
|
||||
]]>
|
||||
</screen>
|
||||
</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 xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xml:id="function.sha1-file">
|
||||
<refnamediv>
|
||||
<refname>sha1_file</refname>
|
||||
|
@ -51,6 +51,29 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<para>
|
||||
<example>
|
||||
<title><function>sha1_file</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
foreach(glob('/home/Kalle/myproject/*.php') as $ent)
|
||||
{
|
||||
if(is_dir($ent))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
echo $ent . ' (SHA1: ' . sha1_file($ent) . ')', PHP_EOL;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
<refsect1 role="changelog">
|
||||
&reftitle.changelog;
|
||||
<para>
|
||||
|
|
Loading…
Reference in a new issue