reference/errorfunc/functions/set-error-handler.xml
23906aa9f613d0f67538e4292b220cebf624d5f2
...
...
@@ -9,7 +9,7 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type class="union"><type>string</type><type>array</type><type>object</type><type>null</type></type><methodname>set_error_handler</methodname>
12
+
<type class="union"><type>callable</type><type>null</type></type><methodname>set_error_handler</methodname>
13
13
<methodparam><type class="union"><type>callable</type><type>null</type></type><parameter>callback</parameter></methodparam>
14
14
<methodparam choice="opt"><type>int</type><parameter>error_levels</parameter><initializer><constant>E_ALL</constant></initializer></methodparam>
15
15
</methodsynopsis>
...
...
@@ -18,36 +18,26 @@
18
18
errors in a script.
19
19
</para>
20
20
<para>
21
-
This function can be used for defining your own way of handling errors
22
-
during runtime, for example in applications in which you need to do
23
-
cleanup of data/files when a critical error happens, or when you need
24
-
to trigger an error under certain conditions (using
25
-
<function>trigger_error</function>).
21
+
This function can be used to define custom error handlers during runtime,
22
+
for example in applications which need to do file/data cleanup when a critical
23
+
error happens, or when triggering an error in response to certain conditions
24
+
(using <function>trigger_error</function>).
26
25
</para>
27
26
<para>
28
27
It is important to remember that the standard PHP error handler is completely
29
28
bypassed for the error types specified by <parameter>error_levels</parameter>
30
29
unless the callback function returns &false;.
31
-
<function>error_reporting</function> settings will have no effect and your
32
-
error handler will be called regardless - however you are still able to read
33
-
the current value of
30
+
<function>error_reporting</function> settings will have no effect and the
31
+
error handler will be called regardless - however, it's still possible to
32
+
read the current value of
34
33
<link linkend="ini.error-reporting">error_reporting</link> and act
35
34
appropriately.
36
35
</para>
37
-

38
-
<warning>
39
-
<para>
40
-
Prior to PHP 8.0.0, the <parameter>errno</parameter> value was always
41
-
<literal>0</literal> if the expression which caused the diagnostic
42
-
was prepended by the
43
-
<link linkend="language.operators.errorcontrol">@ error-control operator</link>.
44
-
</para>
45
-
</warning>
46
-

47
36
<para>
48
-
Also note that it is your responsibility to <function>die</function> if
49
-
necessary. If the error-handler function returns, script execution
50
-
will continue with the next statement after the one that caused an error.
37
+
Also note that it is the handler's responsibility to stop the
38
+
script's execution if necessary by calling <function>exit</function>. If the error-handler
39
+
function returns, script execution will continue with the next statement
40
+
after the one that caused an error.
51
41
</para>
52
42
<para>
53
43
The following error types cannot be handled with a user defined
...
...
@@ -73,10 +63,8 @@
73
63
<term><parameter>callback</parameter></term>
74
64
<listitem>
75
65
<para>
76
-
A callback with the following signature.
77
-
&null; may be passed instead, to reset this handler to its default state.
78
-
Instead of a function name, an array containing an object reference
79
-
and a method name can also be supplied.
66
+
If &null; is passed, the handler is reset to its default state.
67
+
Otherwise, the handler is a callback with the following signature:
80
68
</para>
81
69
<para>
82
70
<methodsynopsis>
...
...
@@ -138,7 +126,7 @@
138
126
<warning xmlns="http://docbook.org/ns/docbook">
139
127
<simpara>
140
128
This parameter has been <emphasis>DEPRECATED</emphasis> as of PHP 7.2.0,
141
-
and <emphasis>REMOVED</emphasis> as of PHP 8.0.0. If your function defines
129
+
and <emphasis>REMOVED</emphasis> as of PHP 8.0.0. If the function defines
142
130
this parameter without a default, an error of "too few arguments" will be
143
131
raised when it is called.
144
132
</simpara>
...
...
@@ -172,8 +160,8 @@
172
160
&reftitle.returnvalues;
173
161
<para>
174
162
Returns the previously defined error handler (if any). If
175
-
the built-in error handler is used &null; is returned. &null; is also returned
176
-
in case of an error such as an invalid callback. If the previous error handler
163
+
the built-in error handler is used &null; is returned.
164
+
If the previous error handler
177
165
was a class method, this function will return an indexed array with the class
178
166
and the method name.
179
167
</para>
...
...
@@ -194,14 +182,6 @@
194
182
<row>
195
183
<entry>8.0.0</entry>
196
184
<entry>
197
-
<parameter>errno</parameter> is no longer <literal>0</literal> when
198
-
the expression was suppressed by the
199
-
<link linkend="language.operators.errorcontrol">@ error-control operator</link>
200
-
</entry>
201
-
</row>
202
-
<row>
203
-
<entry>8.0.0</entry>
204
-
<entry>
205
185
<parameter>errcontext</parameter> was removed, and will no longer be passed to user callbacks.
206
186
</entry>
207
187
</row>
208
188