<?php class Foo { public function tryInclude() { try { require $this->getFileName('include'); } catch (Exception $e) { printf("Catched Exception: %s", $e->getMessage()); } } private function getFileName($action) { $file = '/unknown/path/to/file'; if (false === file_exists($file)) { throw new Exception(sprintf('The file for this %s was not found.', $action)); } else { return $file; } } } $instance = new Foo; $instance->tryInclude();
You have javascript disabled. You will not be able to edit any code.