note 109689 added to function.include

From: Date: Thu, 09 Aug 2012 16:34:34 +0000
Subject: note 109689 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-189977@lists.php.net to get a copy of this message
You need to test to see if include() is equal to 1 to see if it's successful. For some reason it tests success instead of failure. So to test if the include failed, you need to test like this: <?php if ((include 'inc/db.php') !== 1) { die('Include failed.'); } ?> The docs say to test against 'OK', which is incorrect, as the return value is int(1); ---- Server IP: 69.147.83.197 Probable Submitter: 98.124.59.194 ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- https://master.php.net/note/edit/109689 Del: integrated -- https://master.php.net/note/delete/109689/integrated Del: useless -- https://master.php.net/note/delete/109689/useless Del: bad code -- https://master.php.net/note/delete/109689/bad+code Del: spam -- https://master.php.net/note/delete/109689/spam Del: non-english -- https://master.php.net/note/delete/109689/non-english Del: in docs -- https://master.php.net/note/delete/109689/in+docs Del: other reasons-- https://master.php.net/note/delete/109689 Reject -- https://master.php.net/note/reject/109689 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#189977) next »