downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

Zip> <RarException::isUsingExceptions
[edit] Last updated: Fri, 30 Nov 2012

view this page in

RarException::setUsingExceptions

(PECL rar >= 2.0.0)

RarException::setUsingExceptionsActivate and deactivate error handling with exceptions

Opis

public static void RarException::setUsingExceptions ( bool $using_exceptions )

If and only if the argument is TRUE, then, instead of emitting warnings and returning a special value indicating error when the UnRAR library encounters an error, an exception of type RarException will be thrown.

Exceptions will also be thrown for the following errors, which occur outside the library (their error code will be -1):

Parametry

using_exceptions

Should be TRUE to activate exception throwing, FALSE to deactivate (the default).

Przykłady

Przykład #1 RarException::setUsingExceptions() example

<?php
var_dump
(RarException::isUsingExceptions());
$arch RarArchive::open("does_not_exist.rar");
var_dump($arch);

RarException::setUsingExceptions(true);
var_dump(RarException::isUsingExceptions());
$arch RarArchive::open("does_not_exist.rar");
var_dump($arch); //not reached
?>

Powyższy przykład wyświetli coś podobnego do:

bool(false)

Warning: RarArchive::open(): Failed to open does_not_exist.rar: ERAR_EOPEN (file open error) in C:\php_rar\trunk\tests\test.php on line 3
bool(false)
bool(true)

Fatal error: Uncaught exception 'RarException' with message 'unRAR internal error: Failed to open does_not_exist.rar: ERAR_EOPEN (file open error)' in C:\php_rar\trunk\tests\test.php:8
Stack trace:
#0 C:\php_rar\trunk\tests\test.php(8): RarArchive::open('does_not_exist....')
#1 {main}
  thrown in C:\php_rar\trunk\tests\test.php on line 8

Zobacz też:



add a note add a note User Contributed Notes RarException::setUsingExceptions - [0 notes]
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites