Re: BUG: require_once() or die(); = fatal error

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: BUG: require_once() or die(); = fatal error
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-171163@lists.php.net to get a copy of this message
This code doesn't make much sense. By definition, if require cannot open a file it throws a fatal error, so you would never hit the "or" case anyway. Hence there is no return code from require and you can't write code like this. If you want to test the return code you need to use 'include' instead. -Rasmus On Wed, 26 Nov 2003, Daevid Vincent wrote: > Using PHP 4.2.2 on Linux RH8: > > In a PHP script run from command line, > > require_once("gibberator_data.php") or die("No Data file found\n"); > > Causes: > > [root@locutus gibberator]# ./gibberator.php > <br /> > <b>Fatal error</b>: Failed opening required '1' > (include_path='.:/php/includes;/usr/share/phpwebtools') in > <b>/home/gibberator/gibberator.php</b> on line <b>13</b><br /> > > However > > require_once("gibberator_data.php"); > > Works just fine. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#171163) next »