note 81812 added to function.require-once

From: Date: Fri, 14 Mar 2008 11:20:57 +0000
Subject: note 81812 added to function.require-once
Groups: php.notes 
Request: Send a blank email to php-notes+get-137052@lists.php.net to get a copy of this message
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. ---- Server IP: 87.124.64.96 Probable Submitter: 217.33.129.226 ---- Manual Page -- http://www.php.net/manual/en/function.require-once.php Edit -- https://master.php.net/note/edit/81812 Del: integrated -- https://master.php.net/note/delete/81812/integrated Del: useless -- https://master.php.net/note/delete/81812/useless Del: bad code -- https://master.php.net/note/delete/81812/bad+code Del: spam -- https://master.php.net/note/delete/81812/spam Del: non-english -- https://master.php.net/note/delete/81812/non-english Del: in docs -- https://master.php.net/note/delete/81812/in+docs Del: other reasons-- https://master.php.net/note/delete/81812 Reject -- https://master.php.net/note/reject/81812 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137052) next »