note 81812 deleted from function.require-once by sobak

From: Date: Fri, 02 Dec 2016 08:24:48 +0000
Subject: note 81812 deleted from function.require-once by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207945@lists.php.net to get a copy of this message
Note Submitter: cnorthcote at underground dot co dot uk ---- Bear in mind that require_once doesn't have a return value (neither does require; since they both halt execution on failure), so this won't work: <? require_once("path/to/myfile.php") or die("Couldn't load myfile"); ?> because you will get a very unhelpful error: PHP Fatal error: require_once() : Failed opening required '1' (include_path='.;C:\\php5\\pear') in C:\path\to\code.php on line 1 This was mentioned on the php-general mailing list in about 2003 but is a gotcha I have seen a few people come across. If you want to check to see if a file was included, use @include() instead.

« previous php.notes (#207945) next »