note 62312 deleted from function.include by felipe
| From: | felipe@php.net | Date: | Mon, 10 Dec 2007 18:23:44 +0000 |
| Subject: | note 62312 deleted from function.include by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133276@lists.php.net to get a copy of this message | ||
Note Submitter: arnold at bean-it dot nl
----
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.