note 11975 added to control-structures.php

From: Date: Fri, 16 Mar 2001 02:00:52 +0000
Subject: note 11975 added to control-structures.php
Groups: php.notes 
Request: Send a blank email to php-notes+get-12453@lists.php.net to get a copy of this message
It would appear that PHP4 does not allow a control structure to open in one included file and close in another. Perhaps it was a terrible idea, but I had a set of pages that included "include/start-page.php3" at the beginning of the page and "include/end-page.php3" at the end. Among other things, start-page.php3 basically had the following code at the end of the file:<p> if (the user isn't logged in) { display_login_form(); } else { ?><p> and the end-page.php3 file began with the right curly bracket that would end that block of logic. This way, I could create a bunch of pages that looked like this:<p> include "include/start-page.php3"; include "all-the-content.php3"; include "include/end-page.php3";<p> and if the user was not logged in, they'd see only a login form and no other content. This worked just fine until I upgraded to php4, which produces parse errors when the logic block in an included file doesn't conclude before EOF. Looks like maybe I'll have to set a variable and test for it all over the place. http://www.php.net/manual/en/control-structures.php

« previous php.notes (#12453) next »