|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2002-09-09 05:19 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 23:00:01 2025 UTC |
is_readable(), file_exists() and possibly other similar functions return Warning stat failed errors if the file for which the function is called is in a directory for which the www user (Apache) does not have permissions to read. The functions still return the appropriate values, but the error output is annoying. While I undestand why the error is occuring, a function with a name such as is_readable should suppress these warnings and simply return false if it cannot read the file. Thanks, Nic. Code and error stuff follow. <?PHP echo $file; echo ": "; if (file_exists($file)) { echo " exists"; } else { echo " dont exist"; } if(is_readable($file)) { echo "readable"; } else {echo "not readable";} ?> In the case below the directory 'poo' is not world readable, but does exist. poo/poo.txt: Warning: stat failed for poo/poo.txt (errno=13 - Permission denied) in /opt/apache_1.3.26/htdocs/is_read_test.php on line 6 dont exist Warning: stat failed for poo/poo.txt (errno=13 - Permission denied) in /opt/apache_1.3.26/htdocs/is_read_test.php on line 12 not readable