1 balupton Aug 30, 2006 10:49
3 balupton Aug 30, 2006 21:47
But wouldn't include_once have a file_exists or even a is_file in it anyway? Hence how it can determine which error to display...
Or does it actually try to include the file, and if something does go wrong, then it sends the error?
That's what this question is really about, wether or not we should check wether the input is valid, when the function returns a error anyway if it's not...
4 blueyed Aug 30, 2006 21:55
I don't understand what you mean..
"@" suppressed error.
"@" in front of a include()/require() suppressed the warning (include)/error (require) PLUS any notices, warnings and errors which occur in the existing file.
Don't waste more time thinking about it..
5 balupton Aug 30, 2006 22:07
well, say in the include function does it look like;
if ( file_exists($file) )
{ /*the include code*/ } else { /*output warning*/ }
or
try { /*the include code*/ } catch (){ /*detect and output the warning*/ }
Like it seems redundant if you are checking if the file exists if the include,require,mkdir,file etc functions check as well...
But yeh, it is a error/warning, so they should be avoided.
6 blueyed Aug 30, 2006 22:18
"for the record", it's done like this (./Zend/zend_language_scanner.c):
if (open_file_for_scanning(file_handle TSRMLS_CC)==FAILURE) {
if (type==ZEND_REQUIRE) {
zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, file_handle->filename);
zend_bailout();
} else {
zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);
}
compilation_successful=0;
..and of course, we want to avoid the warning. That's what both "@" and "file_exists" are about...
It's not more effective IIRC (regarding file system hits) and to get/understand the main reason for the file_exists()-way, just add a (parse) error in _config_TEST.php..!