Re: Require_once return value on error?

From: Date: Fri, 30 Apr 2004 10:50:15 +0000
Subject: Re: Require_once return value on error?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-185033@lists.php.net to get a copy of this message
Vincent DUPONT wrote:
I need to load various php files programatically and I use require_once($file_path) for this purpose. My question is : is there a way to know if the file was found or not? if the file generated an error or not?
RTFM: http://php.net/include "require() and include() are identical in every way except how they handle failure. include() produces a Warning while require() results in a Fatal Error." require_once and include_once behave in the same way. You can check the return value from include() to see if it was successful. If the included file ends with a return statement then you will get that if it succeeds. If not you'll get the value 1 if it succeeds. -- Stuart

« previous php.general (#185033) next »