tags:

views:

83

answers:

4

Is there a limit to the number of included files deep you can go with PHP?

For example:

file1.php includes file2.php which includes file3.php which includes file4.php and so on...

I looked in the php.ini file and did not see anything about it. However, for some reason file3.php is not being included. I have checked the syntax to make sure it was correct for all the includes.

+2  A: 

It is very likely not a nesting problem, but a syntactic issue. If you show the require section in each file it may provide a clue as to the problem.

John Weldon
+5  A: 

If you're using include_once and indirectly attempting to include the same file twice, the second time will have no effect.

Otherwise, try using require() instead of include(), which will raise an error on failure. This will let you know if it's a simple case of a typo'd filename, or if a file can't be found due to improper specification of a relative path.

meagar
A: 

I think that if you need to ask, you're doing something wrong.

.

I remember reading that somewhere...

masher
What does that even mean?
meagar
@masher: What are you even doing here, considering this whole site is about asking questions?
FrustratedWithFormsDesigner
This is where I saw it: http://blogs.msdn.com/oldnewthing/archive/2007/03/01/1775759.aspxThe basic premise is that if you're worried about hitting a limit somewhere, then there is probably some other way to do it, or your design in the first place is flawed.
masher
A: 

No, there is no limit.

The engine just keeps opening files and reading them in. This must finally stop somewhere for the execution to finish. However, it is possible to use up all of available memory.

So, yes, there is a limit.

Don