Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exclude an if statement?

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 } ?>
like image 345
puyol5 Avatar asked May 29 '26 06:05

puyol5


1 Answers

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.

like image 68
deceze Avatar answered May 31 '26 05:05

deceze