note 62312 added to function.include

From: Date: Fri, 24 Feb 2006 22:15:51 +0000
Subject: note 62312 added to function.include
Groups: php.notes 
Request: Send a blank email to php-notes+get-104383@lists.php.net to get a copy of this message
Currently there is no clean way to check if a file can be included. Simply including a file which can't be opened causes a warning to be triggered. Suppressing include() with an @ (as often seen below) is not advisable, since parse errors won't be displayed, but will cause the script to die, causing a blank screen. (Happy debugging, hope you're using ZendStudio or some other debugger). The best solution I've come up with is: <?php if (($fp = @fopen($filename, 'r', 1)) and fclose($fp)) include $filename; ?> I believe the functions file_exists(), filesize(), is_readable() and is_writable() should have an use_include_path just like fopen(). If you agree with this, please PLEASE VOTE on bug #6932 (http://bugs.php.net/bug.php?id=6932). This bug has been open for over 5 years. Apparently no one is willing to add this feature. ---- Server IP: 194.109.193.119 Probable Submitter: 213.84.27.165 ---- Manual Page -- http://www.php.net/manual/en/function.include.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+62312 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+62312&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+62312&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+62312&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+62312&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+62312&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+62312&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+62312&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+62312&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#104383) next »