go to bug id or search bugs for
Currently filesize and file_exists (possibly other, these are two I know of) don't appear to support an extra argument like fopen does to make use of the include_path. So the following code would fail if the file is in the include_path:
$file = fread($fp = fopen($filename, 'r', 1), filesize($filename));
Add a Patch
Add a Pull Request
according to the docs: int fopen (string filename, string mode [, int
That's nice. Doesn't solve the feature request though.
Maybe I should clarify, it was the filesize and file_exists function I was hoping would be updated to have an optional argument so they would check the include_path.
Any objection not to add this?
I second this request.
Open since 5 years, since PHP5's autoload even more important
and not even yet assigned... :-/
I third that!
And I would also like to see this argument for the function 'is_readable' and 'is_writable'.
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 @ 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).
The best solution I've come up with is:
if (($fp = @fopen($filename, 'r', 1)) and fclose($fp)) include_once($filename);
Anybody reading this bug PLEASE VOTE that this is important to you, because it doesn't look like anybody is willing to add this (simple) feature.
This is so obvious. It should be there. We should be able to do an easy test BEFORE calling include().
I just think would be great to check before we get any kind of warning or whatever. And I also think would be of great importance to offer a clean code and service.
Why do you guys refuse to add some kind of functionality to the language that would allow people to test if a file is in the in the current include path (any of them) and where the file is located absolutely? Seriously?
Another request for this feature.
file_exists(), is_readable(), is_writable(), and is_file() are begging for this.
This is really needed! Vote for this..
Moreover with auload we can't "officialy" get an excepetion so add this parameter to this function is very important !!!
This is another request for this feature. This has already been said : __autoload users need this feature !
Ping! This is still important (to me).
This is one of those things that really should be added... Why am I still looping though the include paths?
$array = explode(PATH_SEPARATOR, get_include_path());
Come on, let's fix this in under 10 years!
Please add bzopen to the list of functions that really should support "use_include_path".
Having to code full paths or loop through the include_path manually is amateurish for a language this evolved. :(
See dupe: https://bugs.php.net/bug.php?id=48173