Recent Topics

1 Aug 30, 2006 10:49    

if( file_exists(dirname(__FILE__).'/_config_TEST.php') )
	include_once dirname(__FILE__).'/_config_TEST.php';

I saw that in the _basic_config.php file, and wouldn't it be more effecient to do this;

@include_once dirname(__FILE__).'/_config_TEST.php';

I believe i heard Yabba once say that it would be, but yeh...

Your thoughts?

2 Aug 30, 2006 21:37

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..!

3 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 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 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*/ }


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 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);
                } else {
                        zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, file_handle->filename);

..and of course, we want to avoid the warning. That's what both "@" and "file_exists" are about...

Form is loading...

CMS software – This forum is powered by b2evolution CMS, a complete engine for your website.