Page 1 of 1

@include_once($mandator.'/footer.php') == 'OK')

Posted: Thu Jun 23, 2005 10:14 am
by pieai
hi

i like to write smart code (as i belive) ;-)

my question is, if it's faster or better to write:

Code: Select all

//include files that possibly are overwritten
if (file_exists($mandator.'/footer.php'))
{
	include_once($mandator.'/footer.php');
}
else
{
	include_once('footer.php');
}
or that:

Code: Select all

//include files that possibly are overwritten
if (!@include_once($mandator.'/footer.php') == 'OK')
{
	include_once('footer.php');
}
i like the second one.
i think that php first checks if the file exist when including. am i right?

Posted: Thu Jun 23, 2005 10:29 am
by timvw
I always use http://www.php.net/require and http://www.php.net/require_once.

Btw, you might want to think about your "include_path" settings... Because they can be a source for "unexpected" results ;)

Posted: Thu Jun 23, 2005 10:30 am
by pieai
i noticed that if i try to execute the code above that it wont recongize the file. the last result was the following:

Code: Select all

//include files that possibly are overwritten
if (!@include_once($mandator.'/footer.php'))
{
    include_once('footer.php');
}
and that works. anything about performace? any idea about the performance a wrote above?

thanks.
PA