On Fri, Mar 27, 2009 at 10:45 AM, Michael Jones <[email protected]> wrote:
> Essentially, you are acknowledging that there will likely be an error when
> including the file. By wrapping the include in a file_exists($file)
> function, you are actually handling the error, rather than just ignoring
> it. Plus, this way you could have the code do something different if the
> file doesn't exist, whereas if you just ignore the error there is no way for
> the rest of the script to know whether or not the file was included.
If your choice is between throwing the error out or handling it
elegantly, then obviously the latter option is better. But if the
choice is between
@include_once($file);
or
if (file_exists($file)) {
include_once($file);
} //End of code - no error handling intended or desired
what, really, is the difference? I don't see one, except that it took
me longer to type the second one. (Slowdown when evaluating @ aside -
I think that's of arguable benefit anyway. The bottleneck in your
program is likely to be elsewhere.)
Again, I'm only talking about situations where you don't care what the
error is. Obviously if you care what the error is and want to handle
it, you've got to use file_exists.
-Dan
_______________________________________________
UPHPU mailing list
[email protected]
http://uphpu.org/mailman/listinfo/uphpu
IRC: #uphpu on irc.freenode.net