• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How does PHP process includes?

igowerf

Diamond Member
What if I include a file that includes a file that includes a file? Does it start with the last file included and work back up? What if each file has more PHP code in it?

I started wondering about this when I wanted to include another PHP page AND pass some variable to it. Does PHP include the code first, and then process it? Or does PHP process it and then include it?
 
Most languages simply take the line that had the include and put all of that text there, so instead of using the include directive you could just copy/paste the file there.

Also according to their site any variables in scope during the include are available to functions in the include, so there would be no reason to pass variables to an included file, just the functions you call from that included file.
 
Yeah, the namespace of the included file just gets dumped into the original, and the namespace of the original is available to the included file.

So basically, it's included, and then processed.

And for the first question, it will just keep recursing into files. I can't remember what happens when you make a circular include, I'm not sure if it catches it, or if it just exhausts its memory limit, or what. Try it 😛
 
Ah. Got it. Thanks guys.

And I don't think I'm going to try that circular include and run the risk of killing my fancy new hosting account at Dathorn. 😛
 
Back
Top