assert() and assert_options() added

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@30425 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Hartmut Holzgraefe 2000-08-17 19:25:21 +00:00
parent aa3b2dd31a
commit faba3ac0a2

View file

@ -2,6 +2,124 @@
<title>PHP options &amp; information</title>
<titleabbrev>PHP options/info</titleabbrev>
<refentry id="function.assert">
<refnamediv>
<refname>assert</refname>
<refpurpose>Checks if assertion is false</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>int <function>assert</function></funcdef>
<paramdef>string|bool <parameter>assertion</parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
<function>assert</function> will check the given
<parameter>assertion</parameter> and take appropriate
action if its result is <literal>false</literal>.
</para>
<para>
If the <parameter>assertion</parameter> is given as a string it
will be evaluated as PHP code by <function>assert</function>.
The advantages of a string <parameter>assertion</parameter>
are less overhead when assertion checking is off and messages
containing the <parameter>assertion</parameter> expression when
an assertion failes.
</para>
<para>
Assertion should be used as a debugging feature only. You may
use them for sanity-checks that test for conditions that should
always be true and that indicate some programming errors if not
or to check for the presence of certain features like extension
functions or certain system limits and features.
</para>
<para>
Assertions should not be used for normal runtime operations
like input parameter checks. As a rule of thumb your code
should always be able to work correct if assertion checking
is not activated.
</para>
<para>
The behavior of <function>assert</function> may be configured
by <function>assert_options</function> or by .ini-settings
described in that functions manual page.
</para>
</refsect1>
</refentry>
<refentry id="function.assert_options">
<refnamediv>
<refname>assert-options</refname>
<refpurpose>Set/get the various assert flags</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<funcsynopsis>
<funcprototype>
<funcdef>mixed <function>assert_options</function></funcdef>
<paramdef>int <parameter>what</parameter></paramdef>
<paramdef>mixed <parameter><optional>value</optional></parameter></paramdef>
</funcprototype>
</funcsynopsis>
<para>
Using <function>assert_options</function> you may set the various
<function>assert</function> control options or just query their current
settings.
</para>
<table>
<title>assert options</title>
<tgroup cols="4">
<thead>
<row>
<entry>option</entry>
<entry>ini-parameter</entry>
<entry>default</entry>
<entry>description</entry>
</row>
</thead>
<tbody>
<row>
<entry>ASSERT_ACTIVE</entry>
<entry>assert.active</entry>
<entry>1</entry>
<entry>enable <function>assert</function> evaluation</entry>
</row>
<row>
<entry>ASSERT_WARNING</entry>
<entry>assert.warning</entry>
<entry>1</entry>
<entry>issue a PHP warning for each failed assertion</entry>
</row>
<row>
<entry>ASSERT_BAIL</entry>
<entry>assert.bail</entry>
<entry>0</entry>
<entry>terminate execution on failed assertions</entry>
</row>
<row>
<entry>ASSERT_QUIET_EVAL</entry>
<entry>assert.quiet_eval</entry>
<entry>0</entry>
<entry>disable error_reporting during assertion expression evaluation</entry>
</row>
<row>
<entry>ASSERT_CALLBACK</entry>
<entry>assert_callback</entry>
<entry>(null)</entry>
<entry>user function to call on failed assertions</entry>
</row>
</tbody>
</tgroup>
</table>
<para>
<function>assert_options</function> will return the original setting
of any option or <literal>false</literal> on errors.
</para>
</refsect1>
</refentry>
<refentry id="function.error-log">
<refnamediv>
<refname>error_log</refname>