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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
pieai
Forum Newbie
Posts: 2
Joined: Thu Jun 23, 2005 10:07 am

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

Post 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?
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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 ;)
pieai
Forum Newbie
Posts: 2
Joined: Thu Jun 23, 2005 10:07 am

Post 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
Post Reply