PEAR Class Info:

Class Declaration:

class PEAR

File name:
Description:

Base class for other PEAR classes. Provides rudimentary emulation of destructors.

If you want a destructor in your class, inherit PEAR and make a destructor method called _yourclassname (same name as the constructor, but with a "_" prefix). Also, in your constructor you have to call the PEAR constructor: $this->PEAR();. The destructor method will be called without parameters. Note that at in some SAPI implementations (such as Apache), any output during the request shutdown (in which destructors are called) seems to be discarded. If you need to get any debug information from your destructor, use error_log(), syslog() or something similar.

IMPORTANT! To use the emulated destructors you need to create the objects by reference: $obj =& new PEAR_child;

Category

pear

Package
PEAR
Author

Stig Bakken <ssb@php.net>

Tomas V.V. Cox <cox@idecnet.com>

Greg Beaver <cellog@php.net>

Copyright

1997-2006 The PHP Group

License

http://opensource.org/licenses/bsd-license.php New BSD License

Version

Release: 1.9.0

Link
Array
See

PEAR_Error

Since

Class available since PHP 4.0.2

Properties:

Show/Hide parent properties
  • _debug bool

    Whether to enable internal debug messages.

  • _default_error_handler string

    Default error handler (callback) for this object, if error mode is PEAR_ERROR_CALLBACK.

  • _default_error_mode int

    Default error mode for this object.

  • _default_error_options int

    Default error options used for this object when error mode is PEAR_ERROR_TRIGGER.

  • _error_class string

    Which class to use for error objects.

  • _expected_errors array

    An array of expected errors.

_checkDelExpect

top

This method checks unsets an error code if available

Parameters:
  • $error_code required

Method defined in:
/usr/share/php/PEAR.php on line 413
Return

bool true if the error code was unset, false otherwise

Access

private

Since

PHP 4.3.0

delExpect

top

This method deletes all occurences of the specified element from the expected error codes stack.

Parameters:
  • mixed $error_code required

    error code that should be deleted

Method defined in:
/usr/share/php/PEAR.php on line 443
Return

mixed list of error codes that were deleted or error

Access

public

Since

PHP 4.3.0

expectError

top

This method is used to tell which errors you expect to get. Expected errors are always returned with error mode PEAR_ERROR_RETURN. Expected error codes are stored in a stack, and this method pushes a new element onto it. The list of expected errors are in effect until they are popped off the stack with the popExpect() method.

Note that this method can not be called statically

Parameters:
  • mixed $code optional '*'

    a single error code or an array of error codes to expect

Method defined in:
/usr/share/php/PEAR.php on line 378
Return

int the new depth of the "expected errors" stack

Access

public

getStaticProperty

top

If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. Eg. in your method(s) do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar'); You MUST use a reference, or they will not persist!

Parameters:
  • string $class required

    The calling classname, to prevent clashes

  • string $var required

    The variable to retrieve.

Method defined in:
/usr/share/php/PEAR.php on line 215
Access

public

Return

mixed A reference to the variable. If not set it will be auto initialised to NULL.

isError

top

Tell whether a value is a PEAR error.

Parameters:
  • mixed $data required

    the value to test

  • int $code optional NULL

    if $data is an error object, return true only if $code is a string and $obj->getMessage() == $code or $code is an integer and $obj->getCode() == $code

Method defined in:
/usr/share/php/PEAR.php on line 266
Access

public

Return

bool true if parameter is an error

loadExtension

top

OS independant PHP extension load. Remember to take care on the correct extension name for case sensitive OSes.

Parameters:
  • string $ext required

    The extension name

Method defined in:
/usr/share/php/PEAR.php on line 736
Return

bool Success or not on the dl() call

_PEAR

top

Destructor (the emulated type of...). Does nothing right now, but is included for forward compatibility, so subclass destructors should always call it.

See the note in the class desciption about output from destructors.

Method defined in:
/usr/share/php/PEAR.php on line 194
Access

public

Return

void

PEAR

top

Constructor. Registers this object in $_PEAR_destructor_object_list for destructor emulation if a destructor object exists.

Parameters:
  • string $error_class optional NULL

    (optional) which class to use for error objects, defaults to PEAR_Error.

Method defined in:
/usr/share/php/PEAR.php on line 155
Access

public

Return

void

popErrorHandling

top

Pop the last error handler used

Method defined in:
/usr/share/php/PEAR.php on line 712
Return

bool Always true

See

PEAR::pushErrorHandling

popExpect

top

This method pops one element off the expected error codes stack.

Method defined in:
/usr/share/php/PEAR.php on line 397
Return

array the list of error codes that were popped

pushErrorHandling

top

Push a new error handler on top of the error handler options stack. With this you can easily override the actual error handler for some code and restore it later with popErrorHandling.

Parameters:
  • mixed $mode required

    (same as setErrorHandling)

  • mixed $options optional NULL

    (same as setErrorHandling)

Method defined in:
/usr/share/php/PEAR.php on line 681
Return

bool Always true

See

PEAR::setErrorHandling

raiseError

top

This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. If the $mode and $options parameters are not specified, the object's defaults are used.

Parameters:
  • mixed $message optional NULL

    a text error message or a PEAR error object

  • int $code optional NULL

    a numeric error code (it is up to your class to define these if you want to use codes)

  • int $mode optional NULL

    One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.

  • mixed $options optional NULL

    If $mode is PEAR_ERROR_TRIGGER, this parameter specifies the PHP-internal error level (one of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). If $mode is PEAR_ERROR_CALLBACK, this parameter specifies the callback function or method. In other error modes this parameter is ignored.

  • string $userinfo optional NULL

    If you need to pass along for example debug information, this parameter is meant for that.

  • string $error_class optional NULL

    The returned error object will be instantiated from this class, if specified.

  • bool $skipmsg optional false

    If true, raiseError will only pass error codes, the error message parameter will be dropped.

Method defined in:
/usr/share/php/PEAR.php on line 511
Access

public

Return

object a PEAR error object

See

PEAR::setErrorHandling

Since

PHP 4.0.5

registerShutdownFunc

top

Use this function to register a shutdown method for static classes.

Parameters:
  • mixed $func required

    The function name (or array of class/method) to call

  • mixed $args optional array ( )

    The arguments to pass to the function

Method defined in:
/usr/share/php/PEAR.php on line 241
Access

public

Return

void

setErrorHandling

top

Sets how errors generated by this object should be handled. Can be invoked both in objects and statically. If called statically, setErrorHandling sets the default behaviour for all PEAR objects. If called in an object, setErrorHandling sets the default behaviour for that object.

When $mode is PEAR_ERROR_CALLBACK, this parameter is expected
   to be the callback function or method.  A callback
   function is a string with the name of the function, a
   callback method is an array of two elements: the element
   at index 0 is the object, and the element at index 1 is
   the name of the method to call in the object.

   When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is
   a printf format string used when printing the error

message.

Parameters:
  • int $mode optional NULL

    One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.

  • mixed $options optional NULL

    When $mode is PEAR_ERROR_TRIGGER, this is the error level (one of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).

Method defined in:
/usr/share/php/PEAR.php on line 323
Access

public

Return

void

See

PEAR_ERROR_RETURN

PEAR_ERROR_PRINT

PEAR_ERROR_TRIGGER

PEAR_ERROR_DIE

PEAR_ERROR_CALLBACK

PEAR_ERROR_EXCEPTION

Since

PHP 4.0.5

staticPopErrorHandling

top

Method defined in:
/usr/share/php/PEAR.php on line 631

staticPushErrorHandling

top

Parameters:
  • $mode required

  • $options optional NULL

Method defined in:
/usr/share/php/PEAR.php on line 596

throwError

top

Simpler form of raiseError with fewer options. In most cases message, code and userinfo are enough.

Parameters:
  • string $message optional NULL

  • $code optional NULL

  • $userinfo optional NULL

Method defined in:
/usr/share/php/PEAR.php on line 582