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!
if ($page = 0)
{ include 'myfile.php';
}
else
{ include 'myotherfile.php';
}
Will inlude only include myfile if $page == 0 or will the PHP engine include both files before executing the code?
The reason I ask is that one of my scripts are getting quite unweildly (8000 lines+) and I'm wondering if pageload time and overhead would be lessed if I split it into several pages that I can include where I needed it.
In your example it will only include the one file. Depending on the value. I use includes to break apart many of my pages. For example almost always when i have a page that will pass other variables to the same page like sorting order i will have 2 includes. The main page with nothing passes and then the 2nd part with variables passed. Easier for me to work on one part at a time.
The includes will only be executed once it has been passed through by PHP. Let's say your include file contains 5 lines of echo statement. After showing the 5 lines, it will then continue on with where it left off.