Posted by Gleep on 08/09/06 17:48
On Wed, 9 Aug 2006 17:36:15 +0200, "Pugi!" <reply@group.svp> wrote:
>Hi,
>How can you catch a fatal error that occurs when you use a
>require_once("myfile.php") and the file dioesn't exist ?
>I tried:
>try {
> require_once("p.php");
>} catch (Exception $e) {
> echo $e->getMessage();
>}
>but it returns
>Warning: require_once(p.php) [function.require-once]: failed to open stream:
>No such file or directory in D:\apache\xampp\htdocs\site\untitled.php on
>line 12
>
>Fatal error: require_once() [function.require]: Failed opening required
>'p.php' (include_path='.;D:\apache\xampp\php\pear\') in
>D:\apache\xampp\htdocs\site\untitled.php on line 12
>
>So the try/catch is in fact completely ignored.
>
>Pugi!
>
Switch statements to include_once then if there is an error at least it shows up and gives
you a clue how to fix.
Navigation:
[Reply to this message]
|