I have to PHP files, one contains variables, some of which contains PHP code:
/* variables.php */
<?php
$oneVariable = "Hello";
$anotherVariable = "<<<EOF
<h1>Headline</h1>
<p>Text</p>
<?php echo "I whish this would work!" ?>
EOF;
And another one that I access:
/* output.php */
include("variables.php");
echo "$oneVariable World!";
echo "$anotherVariable";
When accessing output.php through a browser I will get:
Hello World!
Headline
Text
<?php echo "I whish this would work!" ?>
But I'd like the php code in the heredoc to be parsed so that I only see "I whish this would work!".
How can I accomplish that?
EDIT: Don't want to ruin the question by editing out my original example, so here's another one:
I'm want to be able to have one template file:
/* index.php */
<?php
include("article.php");
?>
<title><?php echo "$title" ?></title>
<?php echo "$articleContents" ?>
And a bunch of files containing data for articles, for example this one:
/* article.php */
<?php
$title = "About grapes";
$articleContents = <<<EOF
<h1>The wrath</h1>
<p>Even though the title of this article is <?php echo "$title" ?>,
what I'm personally really into is raisins!</p>
EOF;
When I request index.php
I want to get the "formatted" article.