I am having a problem with putting partial bits of PHP code into an include file. Essentially, the situation is like in the following example:
<?php
$x=1;
if ($x==1) { echo 'test'; }
?>
This yields test. I now replace this with
<?php
$x=1;
if ($x==1) { include('test_incl.php') ;
?>
with test_incl.php
<?php echo 'test'; } ?>
As the include file just adds the code back on that was taken out in the original code, I would expect it to work as well, but instead I am getting "Parse error: syntax error, unexpected end of file".
Any clues what is going on here?
A further explanation:
I need to put a conditional around a block of code in one language version of our shopping cart but not others. So my idea was to include the PHP files where the opening and closing part of the conditionals should be, which would keep the core code for all versions identical, with only the includes differing (this how the language specific features are dealt with anyway for this shopping cart).
From what I have read, the PHP engine parses the includes in the flow of the code, so I don't understand why I get the end of file error (which suggests that the include has actually not been parsed yet when the end of the parent code is reached.
Also, I have used this kind of method successfully before with Javascript/HTML includes.