Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Programming: which is better, "file_exists" or "is_readable"?
sirlancelot
New
Just a general programming question, I looked around the internet and couldn't find any "best practice" articles stating if one or the other is better.
When attempting to include user-editable files, I'm inclined to use "is_readable" because it checks for two things: existence, access. What I don't know is how well it works cross-platform. There was a bug before PHP 5.1 where this function would ignore ACLs.
I've seen code where people use
What would you recommend?
When attempting to include user-editable files, I'm inclined to use "is_readable" because it checks for two things: existence, access. What I don't know is how well it works cross-platform. There was a bug before PHP 5.1 where this function would ignore ACLs.
I've seen code where people use
if (file_exists($File) && is_readable($File))
and that just seems ridiculous and slow.What would you recommend?
0
This discussion has been closed.
Comments
The PHP 5+ side of my brain says wrap the code in a try/catch since it's apparently not foolproof.
I always forget about the try/catch blocks. I'll have to do some tests right after I move my server to PHP 5
Thanks for the reminder.