Is it somehow possible to exclude an if statement to two different files? When I write something like the following code, it gives a parse error: syntax error, unexpected end of file. Apparently, i always have to close an if statement in the same included file. Is there a way to accomplish what i want?
index.php:
<?php
require "top.inc.php"; // opening the if statement
some code to execute if statement in top.inc.php is true
require "bottom.inc.php"; // closing the if statement
?>
top.inc.php:
<?php if (1 == 1) { ?>
bottom.inc.php:
<?php } ?>
No, it is not possible. Each .php file needs to have complete, valid syntax. includeing files is not exactly the same as copy-and-pasting their content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With