fiprojects fiprojects -5 years ago 126
PHP Question

When is a php include file parsed?

When is a PHP include file parsed? At startup, or during execution?

My web forms call a single php script. Depending on the arguements passed in the URL, a switch/case condition determines what the script will do. Each "case" within the switch has its own include files.

If include files are parsed during initial load, then my php script will take up more memory/time to process which leads me to believe having individual php files called from my web form is better, than having one which includes what it needs.

If include files are parsed when needed (thus, when a branch of the code reaches a specific case statement, that it then performs the include) it tells me my code will be reasonably conservative on memory.

So.... my question... When is a PHP include file parsed? At initial load, or during execution?

(note... I failed to find the answer here, and I have read

Answer Source

Files are included if and when the include statement is reached at runtime. To very succinctly summarise what that means, the following file is never going to be included:

if (false) {
    include 'foo.php';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download