reference/info/functions/assert.xml
b2cbcaea5b0e967d2b2cc6bbfa631343e49a7c28
...
...
@@ -3,118 +3,60 @@
3
3
<refentry xml:id="function.assert" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>assert</refname>
6
-
<refpurpose>Checks if assertion is &false;</refpurpose>
6
+
<refpurpose>Checks an assertion</refpurpose>
7
7
</refnamediv>
8
8

9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
-
<para>PHP 5</para>
12
11
<methodsynopsis>
13
12
<type>bool</type><methodname>assert</methodname>
14
13
<methodparam><type>mixed</type><parameter>assertion</parameter></methodparam>
15
-
<methodparam choice="opt"><type>string</type><parameter>description</parameter></methodparam>
16
-
</methodsynopsis>
17
-
<para>PHP 7</para>
18
-
<methodsynopsis>
19
-
<type>bool</type><methodname>assert</methodname>
20
-
<methodparam><type>mixed</type><parameter>assertion</parameter></methodparam>
21
-
<methodparam choice="opt"><type>Throwable</type><parameter>exception</parameter></methodparam>
14
+
<methodparam choice="opt"><type class="union"><type>Throwable</type><type>string</type><type>null</type></type><parameter>description</parameter><initializer>&null;</initializer></methodparam>
22
15
</methodsynopsis>
23
16
<para>
24
-
<function>assert</function> will check the given
25
-
<parameter>assertion</parameter> and take appropriate action if
26
-
its result is &false;.
17
+
<function>assert</function>
18
+
allows for the definition of expectations: assertions that take effect
19
+
in development and testing environments, but are optimised away to have
20
+
zero cost in production.
21
+
</para>
22
+
<para>
23
+
Assertions should be used as a debugging feature only.
24
+
One use case for them is to act as sanity-checks for preconditions
25
+
that should always be &true; and that if they aren't upheld this indicates
26
+
some programming errors.
27
+
Another use case is to ensure the presence of certain features like
28
+
extension functions or certain system limits and features.
29
+
</para>
30
+
<para>
31
+
As assertions can be configured to be eliminated, they should
32
+
<emphasis>not</emphasis> be used for normal runtime operations like
33
+
input parameter checks. As a rule of thumb code should behave as expected
34
+
even if assertion checking is deactivated.
27
35
</para>
28
-
<refsect2>
29
-
<title>Traditional assertions (PHP 5 and 7)</title>
30
-
<para>
31
-
If the <parameter>assertion</parameter> is given as a string it
32
-
will be evaluated as PHP code by <function>assert</function>.
33
-
The advantages of a string <parameter>assertion</parameter> are
34
-
less overhead when assertion checking is off and messages
35
-
containing the <parameter>assertion</parameter> expression when
36
-
an assertion fails. This means that if you pass a boolean condition
37
-
as <parameter>assertion</parameter> this condition will not show up as
38
-
parameter to the assertion function which you may have defined with the
39
-
<function>assert_options</function> function, the condition is converted
40
-
to a string before calling that handler function, and the boolean &false;
41
-
is converted as the empty string.
42
-
</para>
43
-
<para>
44
-
Assertions should be used as a debugging feature only. You may
45
-
use them for sanity-checks that test for conditions that should
46
-
always be &true; and that indicate some programming errors if not
47
-
or to check for the presence of certain features like extension
48
-
functions or certain system limits and features.
49
-
</para>
50
-
<para>
51
-
Assertions should not be used for normal runtime operations like
52
-
input parameter checks. As a rule of thumb your code should
53
-
always be able to work correctly if assertion checking is not
54
-
activated.
55
-
</para>
56
-
<para>
57
-
The behavior of <function>assert</function> may be configured by
58
-
<function>assert_options</function> or by .ini-settings described
59
-
in that functions manual page.
60
-
</para>
61
-
<para>
62
-
The <function>assert_options</function> function and/or
63
-
<constant>ASSERT_CALLBACK</constant> configuration directive allow a
64
-
callback function to be set to handle failed assertions.
65
-
</para>
66
-
<para>
67
-
<function>assert</function> callbacks are particularly useful for
68
-
building automated test suites because they allow you to easily
69
-
capture the code passed to the assertion, along with information
70
-
on where the assertion was made. While this information can be
71
-
captured via other methods, using assertions makes it much faster
72
-
and easier!
73
-
</para>
74
-
<para>
75
-
The callback function should accept three arguments. The first
76
-
argument will contain the file the assertion failed in. The
77
-
second argument will contain the line the assertion failed on and
78
-
the third argument will contain the expression that failed (if
79
-
any &#x2014; literal values such as 1 or "two" will not be passed via
80
-
this argument). Users of PHP 5.4.8 and later may also provide a fourth
81
-
optional argument, which will contain the
82
-
<parameter>description</parameter> given to <function>assert</function>, if
83
-
it was set.
84
-
</para>
85
-
</refsect2>
86
-
<refsect2 xml:id="function.assert.expectations">
87
-
<title>Expectations (PHP 7 only)</title>
88
-
<para>
89
-
<function>assert</function> is a language construct in PHP 7, allowing for
90
-
the definition of expectations: assertions that take effect in development
91
-
and testing environments, but are optimised away to have zero cost in
92
-
production.
93
-
</para>
94
-
<para>
95
-
While <function>assert_options</function> can still be used to control
96
-
behaviour as described above for backward compatibility reasons, PHP 7
97
-
only code should use the two new configuration directives to control
98
-
the behaviour of <function>assert</function> and not call
99
-
<function>assert_options</function>.
100
-
</para>
36
+
<para>
37
+
<function>assert</function> will check that the expectation given in
38
+
<parameter>assertion</parameter> holds.
39
+
If not, and thus the result is &false;, it will take the appropriate action
40
+
depending on how <function>assert</function> was configured.
41
+
</para>
42
+

43
+
<para>
44
+
The behaviour of <function>assert</function> is dictated by the
45
+
following INI settings:
101
46
<table>
102
-
<title>
103
-
PHP 7 configuration directives for <function>assert</function>
104
-
</title>
105
-
<tgroup cols="3">
47
+
<title>Assert &ConfigureOptions;</title>
48
+
<tgroup cols="4">
106
49
<thead>
107
50
<row>
108
-
<entry>Directive</entry>
109
-
<entry>Default value</entry>
110
-
<entry>Possible values</entry>
51
+
<entry>&Name;</entry>
52
+
<entry>&Default;</entry>
53
+
<entry>&Description;</entry>
54
+
<entry>&Changelog;</entry>
111
55
</row>
112
56
</thead>
113
57
<tbody>
114
58
<row>
115
-
<entry>
116
-
<link linkend="ini.zend.assertions">zend.assertions</link>
117
-
</entry>
59
+
<entry><link linkend="ini.zend.assertions">zend.assertions</link></entry>
118
60
<entry><literal>1</literal></entry>
119
61
<entry>
120
62
<simplelist>
...
...
@@ -130,33 +72,84 @@
130
72
</member>
131
73
</simplelist>
132
74
</entry>
75
+
<entry/>
133
76
</row>
134
77
<row>
78
+
<entry><link linkend="ini.assert.active">assert.active</link></entry>
79
+
<entry>&true;</entry>
135
80
<entry>
81
+
If &false;, <function>assert</function> does not check the expectation
82
+
and returns &true;, unconditionally.
83
+
</entry>
84
+
<entry>
85
+
Deprecated as of PHP 8.3.0.
86
+
</entry>
87
+
</row>
88
+
<row>
89
+
<entry><link linkend="ini.assert.callback">assert.callback</link></entry>
90
+
<entry>&null;</entry>
91
+
<entry>
92
+
A user defined function to call when an assertion fails.
93
+
It's signature should be:
94
+
<methodsynopsis role="procedural">
95
+
<type>void</type><methodname>assert_callback</methodname>
96
+
<methodparam><type>string</type><parameter>file</parameter></methodparam>
97
+
<methodparam><type>int</type><parameter>line</parameter></methodparam>
98
+
<methodparam><type>null</type><parameter>assertion</parameter></methodparam>
99
+
<methodparam choice="opt"><type>string</type><parameter>description</parameter></methodparam>
100
+
</methodsynopsis>
101
+
</entry>
102
+
<entry>
103
+
Prior to PHP 8.0.0, the signature of the callback should be:
104
+
<methodsynopsis role="procedural">
105
+
<type>void</type><methodname>assert_callback</methodname>
106
+
<methodparam><type>string</type><parameter>file</parameter></methodparam>
107
+
<methodparam><type>int</type><parameter>line</parameter></methodparam>
108
+
<methodparam><type>string</type><parameter>assertion</parameter></methodparam>
109
+
<methodparam choice="opt"><type>string</type><parameter>description</parameter></methodparam>
110
+
</methodsynopsis>
111
+
Deprecated as of PHP 8.3.0.
112
+
</entry>
113
+
</row>
114
+
<row>
115
+
<entry><link linkend="ini.assert.exception">assert.exception</link></entry>
116
+
<entry>&true;</entry>
117
+
<entry>
118
+
If &true; will throw an <classname>AssertionError</classname> if the
119
+
expectation isn't upheld.
120
+
</entry>
121
+
<entry>
122
+
Deprecated as of PHP 8.3.0.
123
+
</entry>
124
+
</row>
125
+
<row>
126
+
<entry><link linkend="ini.assert.bail">assert.bail</link></entry>
127
+
<entry>&false;</entry>
128
+
<entry>
129
+
If &true; will abort execution of the PHP script if the
130
+
expectation isn't upheld.
131
+
</entry>
132
+
<entry>
133
+
Deprecated as of PHP 8.3.0.
134
+
</entry>
135
+
</row>
136
+
<row>
137
+
<entry><link linkend="ini.assert.warning">assert.warning</link></entry>
138
+
<entry>&true;</entry>
139
+
<entry>
140
+
If &true;, will emit an <constant>E_WARNING</constant> if the
141
+
expectation isn't upheld. This INI setting is ineffective if
136
142
<link linkend="ini.assert.exception">assert.exception</link>
143
+
is enabled.
137
144
</entry>
138
-
<entry><literal>0</literal></entry>
139
145
<entry>
140
-
<simplelist>
141
-
<member>
142
-
<literal>1</literal>: throw when the assertion fails, either by
143
-
throwing the object provided as the <parameter>exception</parameter>
144
-
or by throwing a new <classname>AssertionError</classname> object if
145
-
<parameter>exception</parameter> wasn't provided
146
-
</member>
147
-
<member>
148
-
<literal>0</literal>: use or generate a
149
-
<classname>Throwable</classname> as described above, but only
150
-
generate a warning based on that object rather than throwing it
151
-
(compatible with PHP 5 behaviour)
152
-
</member>
153
-
</simplelist>
146
+
Deprecated as of PHP 8.3.0.
154
147
</entry>
155
148
</row>
156
149
</tbody>
157
150
</tgroup>
158
151
</table>
159
-
</refsect2>
152
+
</para>
160
153
</refsect1>
161
154

162
155
<refsect1 role="parameters">
...
...
@@ -167,32 +160,60 @@
167
160
<term><parameter>assertion</parameter></term>
168
161
<listitem>
169
162
<para>
170
-
The assertion. In PHP 5, this must be either a <type>string</type> to
171
-
be evaluated or a <type>boolean</type> to be tested. In PHP 7, this may
172
-
also be any expression that returns a value, which will be executed and
173
-
the result used to indicate whether the assertion succeeded or failed.
163
+
This is any expression that returns a value, which will be executed
164
+
and the result is used to indicate whether the assertion succeeded or failed.
174
165
</para>
166
+

167
+
<warning>
168
+
<para>
169
+
Prior to PHP 8.0.0, if <parameter>assertion</parameter> was a
170
+
<type>string</type> it was interpreted as PHP code and executed via
171
+
<function>eval</function>.
172
+
This string would be passed to the callback as the third argument.
173
+
This behaviour was <emphasis>DEPRECATED</emphasis> in PHP 7.2.0,
174
+
and <emphasis>REMOVED</emphasis> in PHP 8.0.0.
175
+
</para>
176
+
</warning>
175
177
</listitem>
176
178
</varlistentry>
177
179
<varlistentry>
178
180
<term><parameter>description</parameter></term>
179
181
<listitem>
180
182
<para>
183
+
If <parameter>description</parameter> is an instance of
184
+
<classname>Throwable</classname>, it will be thrown only if the
185
+
<parameter>assertion</parameter> is executed and fails.
186
+
<note>
187
+
<para>
188
+
As of PHP 8.0.0, this is done <emphasis>prior</emphasis> to calling
189
+
the potentially defined assertion callback.
190
+
</para>
191
+
</note>
192
+
<note>
193
+
<para>
194
+
As of PHP 8.0.0, the &object; will be thrown regardless of the configuration of
195
+
<link linkend="ini.assert.exception">assert.exception</link>.
196
+
</para>
197
+
</note>
198
+
<note>
199
+
<para>
200
+
As of PHP 8.0.0, the
201
+
<link linkend="ini.assert.bail">assert.bail</link>
202
+
setting has no effect in this case.
203
+
</para>
204
+
</note>
205
+
</para>
206
+
<para>
207
+
If <parameter>description</parameter> is a &string; this message
208
+
will be used if an exception or a warning is emitted.
181
209
An optional description that will be included in the failure message if
182
210
the <parameter>assertion</parameter> fails.
183
211
</para>
184
-
</listitem>
185
-
</varlistentry>
186
-
<varlistentry>
187
-
<term><parameter>exception</parameter></term>
188
-
<listitem>
189
212
<para>
190
-
In PHP 7, the second parameter can be a
191
-
<classname>Throwable</classname> object instead of a descriptive
192
-
<type>string</type>, in which case this is the object that will be
193
-
thrown if the assertion fails and the
194
-
<link linkend="ini.assert.exception">assert.exception</link>
195
-
configuration directive is enabled.
213
+
If <parameter>description</parameter> is omitted.
214
+
<!-- This does not happen if &null; is passed ... -->
215
+
A default description equal to the source code for the invocation of
216
+
<function>assert</function> is created at compile time.
196
217
</para>
197
218
</listitem>
198
219
</varlistentry>
...
...
@@ -203,7 +224,18 @@
203
224
<refsect1 role="returnvalues">
204
225
&reftitle.returnvalues;
205
226
<para>
206
-
&false; if the assertion is false, &true; otherwise.
227
+
<function>assert</function> will always return &true; if at least one of the following is true:
228
+
</para>
229
+
<simplelist>
230
+
<member><literal>zend.assertions=0</literal></member>
231
+
<member><literal>zend.assertions=-1</literal></member>
232
+
<member><literal>assert.exception=1</literal></member>
233
+
<member><literal>assert.bail=1</literal></member>
234
+
<member>A custom exception object is passed to <parameter>description</parameter>.</member>
235
+
</simplelist>
236
+
<para>
237
+
If none of the conditions are true <function>assert</function> will return &true; if
238
+
<parameter>assertion</parameter> is truthy and &false; otherwise.
207
239
</para>
208
240
</refsect1>
209
241

...
...
@@ -220,23 +252,60 @@
220
252
</thead>
221
253
<tbody>
222
254
<row>
223
-
<entry>7.0.0</entry>
255
+
<entry>8.3.0</entry>
256
+
<entry>
257
+
All <literal>assert.</literal> INI settings have been deprecated.
258
+
</entry>
259
+
</row>
260
+
<row>
261
+
<entry>8.0.0</entry>
262
+
<entry>
263
+
<function>assert</function> will no longer evaluate string arguments, instead they will be
264
+
treated like any other argument. <code>assert($a == $b)</code> should be used instead of
265
+
<code>assert('$a == $b')</code>. The <literal>assert.quiet_eval</literal> &php.ini; directive and
266
+
the <constant>ASSERT_QUIET_EVAL</constant> constant have also been removed, as they would no longer
267
+
have any effect.
268
+
</entry>
269
+
</row>
270
+
<row>
271
+
<entry>8.0.0</entry>
272
+
<entry>
273
+
If <parameter>description</parameter> is an instance of
274
+
<classname>Throwable</classname>, the object is thrown if the assertion
275
+
fails, regardless of the value of
276
+
<link linkend="ini.assert.exception">assert.exception</link>.
277
+
</entry>
278
+
</row>
279
+
<row>
280
+
<entry>8.0.0</entry>
281
+
<entry>
282
+
If <parameter>description</parameter> is an instance of
283
+
<classname>Throwable</classname>, no user callback is called even
284
+
if it set.
285
+
</entry>
286
+
</row>
287
+
<row>
288
+
<entry>8.0.0</entry>
289
+
<entry>
290
+
Declaring a function called <literal>assert()</literal> inside a namespace is
291
+
no longer allowed, and issues <constant>E_COMPILE_ERROR</constant>.
292
+
</entry>
293
+
</row>
294
+
<row>
295
+
<entry>7.3.0</entry>
224
296
<entry>
225
-
<function>assert</function> is now a language construct and not a
226
-
function. <function>assertion</function> can now be an expression.
227
-
The second parameter is now interpreted either as an
228
-
<parameter>exception</parameter> (if a
229
-
<classname>Throwable</classname> object is given), or as the
230
-
<parameter>description</parameter> supported from PHP 5.4.8 onwards.
297
+
Declaring a function called <literal>assert()</literal> inside a namespace
298
+
became deprecated. Such declaration now emits an <constant>E_DEPRECATED</constant>.
231
299
</entry>
232
300
</row>
233
301
<row>
234
-
<entry>5.4.8</entry>
302
+
<entry>7.2.0</entry>
235
303
<entry>
236
-
The <parameter>description</parameter> parameter was added. The
237
-
<parameter>description</parameter> is also now provided to a callback
238
-
function in <constant>ASSERT_CALLBACK</constant> mode as the fourth
239
-
argument.
304
+
Usage of a <type>string</type> as the <parameter>assertion</parameter>
305
+
became deprecated. It now emits an <constant>E_DEPRECATED</constant>
306
+
notice when both <link linkend="ini.assert.active">assert.active</link>
307
+
and <link linkend="ini.zend.assertions">zend.assertions</link> are set
308
+
to <literal>1</literal>.
240
309
</entry>
241
310
</row>
242
311
</tbody>
...
...
@@ -247,174 +316,99 @@
247
316

248
317
<refsect1 role="examples">
249
318
&reftitle.examples;
250
-
<refsect2>
251
-
<title>Traditional assertions (PHP 5 and 7)</title>
252
-
<para>
253
-
<example>
254
-
<title>Handle a failed assertion with a custom handler</title>
255
-
<programlisting role="php">
256
-
<![CDATA[
257
-
<?php
258
-
// Active assert and make it quiet
259
-
assert_options(ASSERT_ACTIVE, 1);
260
-
assert_options(ASSERT_WARNING, 0);
261
-
assert_options(ASSERT_QUIET_EVAL, 1);
262
-

263
-
// Create a handler function
264
-
function my_assert_handler($file, $line, $code)
265
-
{
266
-
echo "<hr>Assertion Failed:
267
-
File '$file'<br />
268
-
Line '$line'<br />
269
-
Code '$code'<br /><hr />";
270
-
}
271
-

272
-
// Set up the callback
273
-
assert_options(ASSERT_CALLBACK, 'my_assert_handler');
274
-

275
-
// Make an assertion that should fail
276
-
assert('mysql_query("")');
277
-
?>
278
-
]]>
279
-
</programlisting>
280
-
</example>
281
-
</para>
282
-
<para>
283
-
<example>
284
-
<title>Using a custom handler to print a description</title>
285
-
<programlisting role="php">
286
-
<![CDATA[
287
-
<?php
288
-
// Active assert and make it quiet
289
-
assert_options(ASSERT_ACTIVE, 1);
290
-
assert_options(ASSERT_WARNING, 0);
291
-
assert_options(ASSERT_QUIET_EVAL, 1);
292
-

293
-
// Create a handler function
294
-
function my_assert_handler($file, $line, $code, $desc = null)
295
-
{
296
-
echo "Assertion failed at $file:$line: $code";
297
-
if ($desc) {
298
-
echo ": $desc";
299
-
}
300
-
echo "\n";
301
-
}
302
-

303
-
// Set up the callback
304
-
assert_options(ASSERT_CALLBACK, 'my_assert_handler');
305
-

306
-
// Make an assertion that should fail
307
-
assert('2 < 1');
308
-
assert('2 < 1', 'Two is less than one');
309
-
?>
310
-
]]>
311
-
</programlisting>
312
-
&example.outputs;
313
-
<screen>
314
-
<![CDATA[
315
-
Assertion failed at test.php:21: 2 < 1
316
-
Assertion failed at test.php:22: 2 < 1: Two is less than one
317
-
]]>
318
-
</screen>
319
-
</example>
320
-
</para>
321
-
</refsect2>
322
-
<refsect2>
323
-
<title>Expectations (PHP 7 only)</title>
324
319
<example>
325
-
<title>Expectations without a custom exception</title>
320
+
<title><function>assert</function> example</title>
326
321
<programlisting role="php">
327
322
<![CDATA[
328
323
<?php
329
-
assert(true == false);
324
+
assert(1 > 2);
330
325
echo 'Hi!';
331
-
?>
332
326
]]>
333
327
</programlisting>
334
328
<para>
335
-
With <link linkend="ini.zend.assertions">zend.assertions</link> set to 0,
329
+
If assertions are enabled (<link linkend="ini.zend.assertions"><literal>zend.assertions=1</literal></link>)
336
330
the above example will output:
337
331
</para>
338
332
<screen>
339
333
<![CDATA[
340
-
Hi!
334
+
Fatal error: Uncaught AssertionError: assert(1 > 2) in example.php:2
335
+
Stack trace:
336
+
#0 example.php(2): assert(false, 'assert(1 > 2)')
337
+
#1 {main}
338
+
thrown in example.php on line 2
341
339
]]>
342
340
</screen>
343
341
<para>
344
-
With <link linkend="ini.zend.assertions">zend.assertions</link> set to 1
345
-
and <link linkend="ini.assert.exception">assert.exception</link> set to 0,
342
+
If assertions are disabled (<literal>zend.assertions=0</literal> or <literal>zend.assertions=-1</literal>)
346
343
the above example will output:
347
344
</para>
348
345
<screen>
349
346
<![CDATA[
350
-
Warning: assert(): assert(true == false) failed in - on line 2
351
347
Hi!
352
348
]]>
353
349
</screen>
350
+
</example>
351
+
<example>
352
+
<title>Using a custom message</title>
353
+
<programlisting role="php">
354
+
<![CDATA[
355
+
<?php
356
+
assert(1 > 2, "Expected one to be greater than two");
357
+
echo 'Hi!';
358
+
]]>
359
+
</programlisting>
354
360
<para>
355
-
With <link linkend="ini.zend.assertions">zend.assertions</link> set to 1
356
-
and <link linkend="ini.assert.exception">assert.exception</link> set to 1,
357
-
the above example will output:
361
+
If assertions are enabled the above example will output:
358
362
</para>
359
363
<screen>
360
364
<![CDATA[
361
-
Fatal error: Uncaught AssertionError: assert(true == false) in -:2
365
+
Fatal error: Uncaught AssertionError: Expected one to be greater than two in example.php:2
362
366
Stack trace:
363
-
#0 -(2): assert(false, 'assert(true == ...')
367
+
#0 example.php(2): assert(false, 'Expected one to...')
364
368
#1 {main}
365
-
thrown in - on line 2
369
+
thrown in example.php on line 2
370
+
]]>
371
+
</screen>
372
+
<para>
373
+
If assertions are disabled the above example will output:
374
+
</para>
375
+
<screen>
376
+
<![CDATA[
377
+
Hi!
366
378
]]>
367
379
</screen>
368
380
</example>
369
381
<example>
370
-
<title>Expectations with a custom exception</title>
382
+
<title>Using a custom exception class</title>
371
383
<programlisting role="php">
372
384
<![CDATA[
373
385
<?php
374
-
class CustomError extends AssertionError {}
386
+
class ArithmeticAssertionError extends AssertionError {}
375
387

376
-
assert(true == false, new CustomError('True is not false!'));
388
+
assert(1 > 2, new ArithmeticAssertionError("Expected one to be greater than two"));
377
389
echo 'Hi!';
378
-
?>
379
390
]]>
380
391
</programlisting>
381
392
<para>
382
-
With <link linkend="ini.zend.assertions">zend.assertions</link> set to 0,
383
-
the above example will output:
384
-
</para>
385
-
<screen>
386
-
<![CDATA[
387
-
Hi!
388
-
]]>
389
-
</screen>
390
-
<para>
391
-
With <link linkend="ini.zend.assertions">zend.assertions</link> set to 1
392
-
and <link linkend="ini.assert.exception">assert.exception</link> set to 0,
393
-
the above example will output:
393
+
If assertions are enabled the above example will output:
394
394
</para>
395
395
<screen>
396
396
<![CDATA[
397
-
Warning: assert(): CustomError: True is not false! in -:4
397
+
Fatal error: Uncaught ArithmeticAssertionError: Expected one to be greater than two in example.php:4
398
398
Stack trace:
399
-
#0 {main} failed in - on line 4
400
-
Hi!
399
+
#0 {main}
400
+
thrown in example.php on line 4
401
401
]]>
402
402
</screen>
403
403
<para>
404
-
With <link linkend="ini.zend.assertions">zend.assertions</link> set to 1
405
-
and <link linkend="ini.assert.exception">assert.exception</link> set to 1,
406
-
the above example will output:
404
+
If assertions are disabled the above example will output:
407
405
</para>
408
406
<screen>
409
407
<![CDATA[
410
-
Fatal error: Uncaught CustomError: True is not false! in -:4
411
-
Stack trace:
412
-
#0 {main}
413
-
thrown in - on line 4
408
+
Hi!
414
409
]]>
415
410
</screen>
416
411
</example>
417
-
</refsect2>
418
412
</refsect1>
419
413

420
414
<refsect1 role="seealso">
...
...
@@ -427,7 +421,6 @@ Stack trace:
427
421
</refsect1>
428
422

429
423
</refentry>
430
-

431
424
<!-- Keep this comment at the end of the file
432
425
Local variables:
433
426
mode: sgml
434
427