Calibur Victorious
Calibur Victorious

Reputation: 638

requiring_once a page required before

i have 2 pages their heads are like this

header:

<?php require_once "database.php"; ?>

page:

<?php require_once "database.php"; 
//some codes; 
require_once "header.php"; ?>

I had to require database again for a script to collect data correctly for a specific page, Would that affect the page performance? Or the _once fixes that?

Upvotes: 1

Views: 30

Answers (1)

user2560539
user2560539

Reputation:

Based on PHP documentation if you had used required_once for a file then it will not be required again. If there is a cost on performance? NO.

The require_once statement is identical to require except PHP will check if the file has already been included, and if so, not include (require) it again.

require_once

Upvotes: 2

Related Questions