3
* PEAR, the PHP Extension and Application Repository
5
* PEAR class and PEAR_Error class
9
* LICENSE: This source file is subject to version 3.0 of the PHP license
10
* that is available through the world-wide-web at the following URI:
11
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
12
* the PHP License and are unable to obtain it through the web, please
13
* send a note to license@php.net so we can mail you a copy immediately.
17
* @author Sterling Hughes <sterling@php.net>
18
* @author Stig Bakken <ssb@php.net>
19
* @author Tomas V.V.Cox <cox@idecnet.com>
20
* @author Greg Beaver <cellog@php.net>
21
* @copyright 1997-2005 The PHP Group
22
* @license http://www.php.net/license/3_0.txt PHP License 3.0
23
* @version CVS: $Id: PEAR.php,v 1.96 2005/09/21 00:12:35 cellog Exp $
24
* @link http://pear.php.net/package/PEAR
25
* @since File available since Release 0.1
31
define('PEAR_ERROR_RETURN', 1);
32
define('PEAR_ERROR_PRINT', 2);
33
define('PEAR_ERROR_TRIGGER', 4);
34
define('PEAR_ERROR_DIE', 8);
35
define('PEAR_ERROR_CALLBACK', 16);
40
define('PEAR_ERROR_EXCEPTION', 32);
42
define('PEAR_ZE2', (function_exists('version_compare') &&
43
version_compare(zend_version(), "2-dev", "ge")));
45
if (substr(PHP_OS, 0, 3) == 'WIN') {
46
define('OS_WINDOWS', true);
47
define('OS_UNIX', false);
48
define('PEAR_OS', 'Windows');
50
define('OS_WINDOWS', false);
51
define('OS_UNIX', true);
52
define('PEAR_OS', 'Unix'); // blatant assumption
55
// instant backwards compatibility
56
if (!defined('PATH_SEPARATOR')) {
58
define('PATH_SEPARATOR', ';');
60
define('PATH_SEPARATOR', ':');
64
$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN;
65
$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE;
66
$GLOBALS['_PEAR_destructor_object_list'] = array();
67
$GLOBALS['_PEAR_shutdown_funcs'] = array();
68
$GLOBALS['_PEAR_error_handler_stack'] = array();
70
@ini_set('track_errors', true);
73
* Base class for other PEAR classes. Provides rudimentary
74
* emulation of destructors.
76
* If you want a destructor in your class, inherit PEAR and make a
77
* destructor method called _yourclassname (same name as the
78
* constructor, but with a "_" prefix). Also, in your constructor you
79
* have to call the PEAR constructor: $this->PEAR();.
80
* The destructor method will be called without parameters. Note that
81
* at in some SAPI implementations (such as Apache), any output during
82
* the request shutdown (in which destructors are called) seems to be
83
* discarded. If you need to get any debug information from your
84
* destructor, use error_log(), syslog() or something similar.
86
* IMPORTANT! To use the emulated destructors you need to create the
87
* objects by reference: $obj =& new PEAR_child;
91
* @author Stig Bakken <ssb@php.net>
92
* @author Tomas V.V. Cox <cox@idecnet.com>
93
* @author Greg Beaver <cellog@php.net>
94
* @copyright 1997-2005 The PHP Group
95
* @license http://www.php.net/license/3_0.txt PHP License 3.0
96
* @version Release: 1.4.5
97
* @link http://pear.php.net/package/PEAR
99
* @since Class available since PHP 4.0.2
100
* @link http://pear.php.net/manual/en/core.pear.php#core.pear.pear
107
* Whether to enable internal debug messages.
115
* Default error mode for this object.
120
var $_default_error_mode = null;
123
* Default error options used for this object when error mode
124
* is PEAR_ERROR_TRIGGER.
129
var $_default_error_options = null;
132
* Default error handler (callback) for this object, if error mode is
133
* PEAR_ERROR_CALLBACK.
138
var $_default_error_handler = '';
141
* Which class to use for error objects.
146
var $_error_class = 'PEAR_Error';
149
* An array of expected errors.
154
var $_expected_errors = array();
161
* Constructor. Registers this object in
162
* $_PEAR_destructor_object_list for destructor emulation if a
163
* destructor object exists.
165
* @param string $error_class (optional) which class to use for
166
* error objects, defaults to PEAR_Error.
170
function PEAR($error_class = null)
172
$classname = strtolower(get_class($this));
174
print "PEAR constructor called, class=$classname\n";
176
if ($error_class !== null) {
177
$this->_error_class = $error_class;
179
while ($classname && strcasecmp($classname, "pear")) {
180
$destructor = "_$classname";
181
if (method_exists($this, $destructor)) {
182
global $_PEAR_destructor_object_list;
183
$_PEAR_destructor_object_list[] = &$this;
184
if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
185
register_shutdown_function("_PEAR_call_destructors");
186
$GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
190
$classname = get_parent_class($classname);
199
* Destructor (the emulated type of...). Does nothing right now,
200
* but is included for forward compatibility, so subclass
201
* destructors should always call it.
203
* See the note in the class desciption about output from
211
printf("PEAR destructor called, class=%s\n", strtolower(get_class($this)));
216
// {{{ getStaticProperty()
219
* If you have a class that's mostly/entirely static, and you need static
220
* properties, you can use this method to simulate them. Eg. in your method(s)
221
* do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
222
* You MUST use a reference, or they will not persist!
225
* @param string $class The calling classname, to prevent clashes
226
* @param string $var The variable to retrieve.
227
* @return mixed A reference to the variable. If not set it will be
228
* auto initialised to NULL.
230
function &getStaticProperty($class, $var)
233
return $properties[$class][$var];
237
// {{{ registerShutdownFunc()
240
* Use this function to register a shutdown method for static
244
* @param mixed $func The function name (or array of class/method) to call
245
* @param mixed $args The arguments to pass to the function
248
function registerShutdownFunc($func, $args = array())
250
$GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
257
* Tell whether a value is a PEAR error.
259
* @param mixed $data the value to test
260
* @param int $code if $data is an error object, return true
261
* only if $code is a string and
262
* $obj->getMessage() == $code or
263
* $code is an integer and $obj->getCode() == $code
265
* @return bool true if parameter is an error
267
function isError($data, $code = null)
269
if (is_a($data, 'PEAR_Error')) {
270
if (is_null($code)) {
272
} elseif (is_string($code)) {
273
return $data->getMessage() == $code;
275
return $data->getCode() == $code;
282
// {{{ setErrorHandling()
285
* Sets how errors generated by this object should be handled.
286
* Can be invoked both in objects and statically. If called
287
* statically, setErrorHandling sets the default behaviour for all
288
* PEAR objects. If called in an object, setErrorHandling sets
289
* the default behaviour for that object.
292
* One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
293
* PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
294
* PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.
296
* @param mixed $options
297
* When $mode is PEAR_ERROR_TRIGGER, this is the error level (one
298
* of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
300
* When $mode is PEAR_ERROR_CALLBACK, this parameter is expected
301
* to be the callback function or method. A callback
302
* function is a string with the name of the function, a
303
* callback method is an array of two elements: the element
304
* at index 0 is the object, and the element at index 1 is
305
* the name of the method to call in the object.
307
* When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is
308
* a printf format string used when printing the error
313
* @see PEAR_ERROR_RETURN
314
* @see PEAR_ERROR_PRINT
315
* @see PEAR_ERROR_TRIGGER
316
* @see PEAR_ERROR_DIE
317
* @see PEAR_ERROR_CALLBACK
318
* @see PEAR_ERROR_EXCEPTION
323
function setErrorHandling($mode = null, $options = null)
325
if (isset($this) && is_a($this, 'PEAR')) {
326
$setmode = &$this->_default_error_mode;
327
$setoptions = &$this->_default_error_options;
329
$setmode = &$GLOBALS['_PEAR_default_error_mode'];
330
$setoptions = &$GLOBALS['_PEAR_default_error_options'];
334
case PEAR_ERROR_EXCEPTION:
335
case PEAR_ERROR_RETURN:
336
case PEAR_ERROR_PRINT:
337
case PEAR_ERROR_TRIGGER:
341
$setoptions = $options;
344
case PEAR_ERROR_CALLBACK:
346
// class/object method callback
347
if (is_callable($options)) {
348
$setoptions = $options;
350
trigger_error("invalid error callback", E_USER_WARNING);
355
trigger_error("invalid error mode", E_USER_WARNING);
364
* This method is used to tell which errors you expect to get.
365
* Expected errors are always returned with error mode
366
* PEAR_ERROR_RETURN. Expected error codes are stored in a stack,
367
* and this method pushes a new element onto it. The list of
368
* expected errors are in effect until they are popped off the
369
* stack with the popExpect() method.
371
* Note that this method can not be called statically
373
* @param mixed $code a single error code or an array of error codes to expect
375
* @return int the new depth of the "expected errors" stack
378
function expectError($code = '*')
380
if (is_array($code)) {
381
array_push($this->_expected_errors, $code);
383
array_push($this->_expected_errors, array($code));
385
return sizeof($this->_expected_errors);
392
* This method pops one element off the expected error codes
395
* @return array the list of error codes that were popped
399
return array_pop($this->_expected_errors);
403
// {{{ _checkDelExpect()
406
* This method checks unsets an error code if available
408
* @param mixed error code
409
* @return bool true if the error code was unset, false otherwise
413
function _checkDelExpect($error_code)
417
foreach ($this->_expected_errors AS $key => $error_array) {
418
if (in_array($error_code, $error_array)) {
419
unset($this->_expected_errors[$key][array_search($error_code, $error_array)]);
423
// clean up empty arrays
424
if (0 == count($this->_expected_errors[$key])) {
425
unset($this->_expected_errors[$key]);
435
* This method deletes all occurences of the specified element from
436
* the expected error codes stack.
438
* @param mixed $error_code error code that should be deleted
439
* @return mixed list of error codes that were deleted or error
443
function delExpect($error_code)
447
if ((is_array($error_code) && (0 != count($error_code)))) {
448
// $error_code is a non-empty array here;
449
// we walk through it trying to unset all
451
foreach($error_code as $key => $error) {
452
if ($this->_checkDelExpect($error)) {
458
return $deleted ? true : PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
459
} elseif (!empty($error_code)) {
460
// $error_code comes alone, trying to unset it
461
if ($this->_checkDelExpect($error_code)) {
464
return PEAR::raiseError("The expected error you submitted does not exist"); // IMPROVE ME
467
// $error_code is empty
468
return PEAR::raiseError("The expected error you submitted is empty"); // IMPROVE ME
476
* This method is a wrapper that returns an instance of the
477
* configured error class with this object's default error
478
* handling applied. If the $mode and $options parameters are not
479
* specified, the object's defaults are used.
481
* @param mixed $message a text error message or a PEAR error object
483
* @param int $code a numeric error code (it is up to your class
484
* to define these if you want to use codes)
486
* @param int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
487
* PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE,
488
* PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.
490
* @param mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter
491
* specifies the PHP-internal error level (one of
492
* E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
493
* If $mode is PEAR_ERROR_CALLBACK, this
494
* parameter specifies the callback function or
495
* method. In other error modes this parameter
498
* @param string $userinfo If you need to pass along for example debug
499
* information, this parameter is meant for that.
501
* @param string $error_class The returned error object will be
502
* instantiated from this class, if specified.
504
* @param bool $skipmsg If true, raiseError will only pass error codes,
505
* the error message parameter will be dropped.
508
* @return object a PEAR error object
509
* @see PEAR::setErrorHandling
512
function &raiseError($message = null,
520
// The error is yet a PEAR error object
521
if (is_object($message)) {
522
$code = $message->getCode();
523
$userinfo = $message->getUserInfo();
524
$error_class = $message->getType();
525
$message->error_message_prefix = '';
526
$message = $message->getMessage();
529
if (isset($this) && isset($this->_expected_errors) && sizeof($this->_expected_errors) > 0 && sizeof($exp = end($this->_expected_errors))) {
530
if ($exp[0] == "*" ||
531
(is_int(reset($exp)) && in_array($code, $exp)) ||
532
(is_string(reset($exp)) && in_array($message, $exp))) {
533
$mode = PEAR_ERROR_RETURN;
536
// No mode given, try global ones
537
if ($mode === null) {
538
// Class error handler
539
if (isset($this) && isset($this->_default_error_mode)) {
540
$mode = $this->_default_error_mode;
541
$options = $this->_default_error_options;
542
// Global error handler
543
} elseif (isset($GLOBALS['_PEAR_default_error_mode'])) {
544
$mode = $GLOBALS['_PEAR_default_error_mode'];
545
$options = $GLOBALS['_PEAR_default_error_options'];
549
if ($error_class !== null) {
551
} elseif (isset($this) && isset($this->_error_class)) {
552
$ec = $this->_error_class;
557
$a = &new $ec($code, $mode, $options, $userinfo);
560
$a = &new $ec($message, $code, $mode, $options, $userinfo);
569
* Simpler form of raiseError with fewer options. In most cases
570
* message, code and userinfo are enough.
572
* @param string $message
575
function &throwError($message = null,
579
if (isset($this) && is_a($this, 'PEAR')) {
580
$a = &$this->raiseError($message, $code, null, null, $userinfo);
583
$a = &PEAR::raiseError($message, $code, null, null, $userinfo);
589
function staticPushErrorHandling($mode, $options = null)
591
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
592
$def_mode = &$GLOBALS['_PEAR_default_error_mode'];
593
$def_options = &$GLOBALS['_PEAR_default_error_options'];
594
$stack[] = array($def_mode, $def_options);
596
case PEAR_ERROR_EXCEPTION:
597
case PEAR_ERROR_RETURN:
598
case PEAR_ERROR_PRINT:
599
case PEAR_ERROR_TRIGGER:
603
$def_options = $options;
606
case PEAR_ERROR_CALLBACK:
608
// class/object method callback
609
if (is_callable($options)) {
610
$def_options = $options;
612
trigger_error("invalid error callback", E_USER_WARNING);
617
trigger_error("invalid error mode", E_USER_WARNING);
620
$stack[] = array($mode, $options);
624
function staticPopErrorHandling()
626
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
627
$setmode = &$GLOBALS['_PEAR_default_error_mode'];
628
$setoptions = &$GLOBALS['_PEAR_default_error_options'];
630
list($mode, $options) = $stack[sizeof($stack) - 1];
633
case PEAR_ERROR_EXCEPTION:
634
case PEAR_ERROR_RETURN:
635
case PEAR_ERROR_PRINT:
636
case PEAR_ERROR_TRIGGER:
640
$setoptions = $options;
643
case PEAR_ERROR_CALLBACK:
645
// class/object method callback
646
if (is_callable($options)) {
647
$setoptions = $options;
649
trigger_error("invalid error callback", E_USER_WARNING);
654
trigger_error("invalid error mode", E_USER_WARNING);
660
// {{{ pushErrorHandling()
663
* Push a new error handler on top of the error handler options stack. With this
664
* you can easily override the actual error handler for some code and restore
665
* it later with popErrorHandling.
667
* @param mixed $mode (same as setErrorHandling)
668
* @param mixed $options (same as setErrorHandling)
670
* @return bool Always true
672
* @see PEAR::setErrorHandling
674
function pushErrorHandling($mode, $options = null)
676
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
677
if (isset($this) && is_a($this, 'PEAR')) {
678
$def_mode = &$this->_default_error_mode;
679
$def_options = &$this->_default_error_options;
681
$def_mode = &$GLOBALS['_PEAR_default_error_mode'];
682
$def_options = &$GLOBALS['_PEAR_default_error_options'];
684
$stack[] = array($def_mode, $def_options);
686
if (isset($this) && is_a($this, 'PEAR')) {
687
$this->setErrorHandling($mode, $options);
689
PEAR::setErrorHandling($mode, $options);
691
$stack[] = array($mode, $options);
696
// {{{ popErrorHandling()
699
* Pop the last error handler used
701
* @return bool Always true
703
* @see PEAR::pushErrorHandling
705
function popErrorHandling()
707
$stack = &$GLOBALS['_PEAR_error_handler_stack'];
709
list($mode, $options) = $stack[sizeof($stack) - 1];
711
if (isset($this) && is_a($this, 'PEAR')) {
712
$this->setErrorHandling($mode, $options);
714
PEAR::setErrorHandling($mode, $options);
720
// {{{ loadExtension()
723
* OS independant PHP extension load. Remember to take care
724
* on the correct extension name for case sensitive OSes.
726
* @param string $ext The extension name
727
* @return bool Success or not on the dl() call
729
function loadExtension($ext)
731
if (!extension_loaded($ext)) {
732
// if either returns true dl() will produce a FATAL error, stop that
733
if ((ini_get('enable_dl') != 1) || (ini_get('safe_mode') == 1)) {
738
} elseif (PHP_OS == 'HP-UX') {
740
} elseif (PHP_OS == 'AIX') {
742
} elseif (PHP_OS == 'OSX') {
747
return @dl('php_'.$ext.$suffix) || @dl($ext.$suffix);
755
// {{{ _PEAR_call_destructors()
757
function _PEAR_call_destructors()
759
global $_PEAR_destructor_object_list;
760
if (is_array($_PEAR_destructor_object_list) &&
761
sizeof($_PEAR_destructor_object_list))
763
reset($_PEAR_destructor_object_list);
764
if (@PEAR::getStaticProperty('PEAR', 'destructlifo')) {
765
$_PEAR_destructor_object_list = array_reverse($_PEAR_destructor_object_list);
767
while (list($k, $objref) = each($_PEAR_destructor_object_list)) {
768
$classname = get_class($objref);
770
$destructor = "_$classname";
771
if (method_exists($objref, $destructor)) {
772
$objref->$destructor();
775
$classname = get_parent_class($classname);
779
// Empty the object list to ensure that destructors are
780
// not called more than once.
781
$_PEAR_destructor_object_list = array();
784
// Now call the shutdown functions
785
if (is_array($GLOBALS['_PEAR_shutdown_funcs']) AND !empty($GLOBALS['_PEAR_shutdown_funcs'])) {
786
foreach ($GLOBALS['_PEAR_shutdown_funcs'] as $value) {
787
call_user_func_array($value[0], $value[1]);
794
* Standard PEAR error class for PHP 4
796
* This class is supserseded by {@link PEAR_Exception} in PHP 5
800
* @author Stig Bakken <ssb@php.net>
801
* @author Tomas V.V. Cox <cox@idecnet.com>
802
* @author Gregory Beaver <cellog@php.net>
803
* @copyright 1997-2005 The PHP Group
804
* @license http://www.php.net/license/3_0.txt PHP License 3.0
805
* @version Release: 1.4.5
806
* @link http://pear.php.net/manual/en/core.pear.pear-error.php
807
* @see PEAR::raiseError(), PEAR::throwError()
808
* @since Class available since PHP 4.0.2
814
var $error_message_prefix = '';
815
var $mode = PEAR_ERROR_RETURN;
816
var $level = E_USER_NOTICE;
820
var $backtrace = null;
826
* PEAR_Error constructor
828
* @param string $message message
830
* @param int $code (optional) error code
832
* @param int $mode (optional) error mode, one of: PEAR_ERROR_RETURN,
833
* PEAR_ERROR_PRINT, PEAR_ERROR_DIE, PEAR_ERROR_TRIGGER,
834
* PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION
836
* @param mixed $options (optional) error level, _OR_ in the case of
837
* PEAR_ERROR_CALLBACK, the callback function or object/method
840
* @param string $userinfo (optional) additional user/debug info
845
function PEAR_Error($message = 'unknown error', $code = null,
846
$mode = null, $options = null, $userinfo = null)
848
if ($mode === null) {
849
$mode = PEAR_ERROR_RETURN;
851
$this->message = $message;
854
$this->userinfo = $userinfo;
855
if (function_exists("debug_backtrace")) {
856
if (@!PEAR::getStaticProperty('PEAR_Error', 'skiptrace')) {
857
$this->backtrace = debug_backtrace();
860
if ($mode & PEAR_ERROR_CALLBACK) {
861
$this->level = E_USER_NOTICE;
862
$this->callback = $options;
864
if ($options === null) {
865
$options = E_USER_NOTICE;
867
$this->level = $options;
868
$this->callback = null;
870
if ($this->mode & PEAR_ERROR_PRINT) {
871
if (is_null($options) || is_int($options)) {
876
printf($format, $this->getMessage());
878
if ($this->mode & PEAR_ERROR_TRIGGER) {
879
trigger_error($this->getMessage(), $this->level);
881
if ($this->mode & PEAR_ERROR_DIE) {
882
$msg = $this->getMessage();
883
if (is_null($options) || is_int($options)) {
885
if (substr($msg, -1) != "\n") {
891
die(sprintf($format, $msg));
893
if ($this->mode & PEAR_ERROR_CALLBACK) {
894
if (is_callable($this->callback)) {
895
call_user_func($this->callback, $this);
898
if ($this->mode & PEAR_ERROR_EXCEPTION) {
899
trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING);
900
eval('$e = new Exception($this->message, $this->code);throw($e);');
908
* Get the error mode from an error object.
910
* @return int error mode
921
* Get the callback function/method from an error object.
923
* @return mixed callback function or object/method array
926
function getCallback() {
927
return $this->callback;
935
* Get the error message from an error object.
937
* @return string full error message
940
function getMessage()
942
return ($this->error_message_prefix . $this->message);
950
* Get error code from an error object
952
* @return int error code
964
* Get the name of this error/exception.
966
* @return string error/exception name (type)
971
return get_class($this);
978
* Get additional user-supplied information.
980
* @return string user-supplied information
983
function getUserInfo()
985
return $this->userinfo;
989
// {{{ getDebugInfo()
992
* Get additional debug information supplied by the application.
994
* @return string debug information
997
function getDebugInfo()
999
return $this->getUserInfo();
1003
// {{{ getBacktrace()
1006
* Get the call backtrace from where the error was generated.
1007
* Supported with PHP 4.3.0 or newer.
1009
* @param int $frame (optional) what frame to fetch
1010
* @return array Backtrace, or NULL if not available.
1013
function getBacktrace($frame = null)
1015
if (defined('PEAR_IGNORE_BACKTRACE')) {
1018
if ($frame === null) {
1019
return $this->backtrace;
1021
return $this->backtrace[$frame];
1025
// {{{ addUserInfo()
1027
function addUserInfo($info)
1029
if (empty($this->userinfo)) {
1030
$this->userinfo = $info;
1032
$this->userinfo .= " ** $info";
1040
* Make a string representation of this object.
1042
* @return string a string with an object summary
1045
function toString() {
1047
$levels = array(E_USER_NOTICE => 'notice',
1048
E_USER_WARNING => 'warning',
1049
E_USER_ERROR => 'error');
1050
if ($this->mode & PEAR_ERROR_CALLBACK) {
1051
if (is_array($this->callback)) {
1052
$callback = (is_object($this->callback[0]) ?
1053
strtolower(get_class($this->callback[0])) :
1054
$this->callback[0]) . '::' .
1057
$callback = $this->callback;
1059
return sprintf('[%s: message="%s" code=%d mode=callback '.
1060
'callback=%s prefix="%s" info="%s"]',
1061
strtolower(get_class($this)), $this->message, $this->code,
1062
$callback, $this->error_message_prefix,
1065
if ($this->mode & PEAR_ERROR_PRINT) {
1068
if ($this->mode & PEAR_ERROR_TRIGGER) {
1069
$modes[] = 'trigger';
1071
if ($this->mode & PEAR_ERROR_DIE) {
1074
if ($this->mode & PEAR_ERROR_RETURN) {
1075
$modes[] = 'return';
1077
return sprintf('[%s: message="%s" code=%d mode=%s level=%s '.
1078
'prefix="%s" info="%s"]',
1079
strtolower(get_class($this)), $this->message, $this->code,
1080
implode("|", $modes), $levels[$this->level],
1081
$this->error_message_prefix,