You are here: Re: How to catch a failed opening required ... (require_once) ? « All PHP « IT news, forums, messages
Re: How to catch a failed opening required ... (require_once) ?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация