Errors/Exceptions

Examples

Example #1 A Phar::__construct() example

<?phptry {$p = new Phar('/path/to/my.phar', FilesystemIterator::CURRENT_AS_FILEINFO | FilesystemIterator::KEY_AS_FILENAME,'my.phar');} catch (UnexpectedValueException $e) { die('Could not open my.phar');} catch (BadMethodCallException $e) { echo 'technically, this cannot happen';}// this works nowecho file_get_contents('phar://my.phar/example.txt');// and works as if we had typedecho file_get_contents('phar:///path/to/my.phar/example.txt');?>