Image

Imagevalera wrote in Imagewebdev

PHP: splitting a loop into separate include files

So here's the model: 3 files. First file starts a loop. Second file has some loop content. Third file closes the loop.

The files are so:

test.php:
<?php
include $_SERVER["DOCUMENT_ROOT"]."/test_header.php";

echo "hello";

include $_SERVER["DOCUMENT_ROOT"]."/test_footer.php";
?>


test_header.php:
<?php
$cond = true;
while($cond) {
?>


test_footer.php:
<?php
$cond = false;
}
?>


PHP complains:
[Thu May 29 01:04:00 2008] [error] [client 127.0.0.1] PHP Parse error: syntax error, unexpected $end in R:\\html\\armenianreporter\\test_header.php on line 4

Line 4 is the one that closes the script in that file ("?>")

So the question is: Can this actually be done? If so, how? Do you know where in the PHP manual this is discussed?