I have the following piece of PHP, which is giving me a:
Parse error: syntax error, unexpected '$author' (T_VARIABLE) in /var/www/html/blog/index.php on line 77
<?php
class Post
{
//Define placeholders
public $title = 'Post Title';
public $timestamp = 'TIMESTAMP';
public $author = 'Author';
public $author_url = '/user/'. $author;
$post_boilerplate = <<<EOF
<div class="blog-post">
<h2 class="blog-post-title"> $this->title </h2>
<p class="blog-post-meta">$this->timestamp by <a href="$this->author_url">$this->author</a></p>
<p>Blah, blah, blah...</p>
</div><!-- /.blog-post -->
EOF;
public function print_post() {
echo $this->post_boilerplate;
}
}
$post = new Post();
$post->print_post();
?>
I've tried commenting out the referenced line as a quick 'fix', but then the error just moves around.
With
//public $author_url = '/user/'. $author;
I get:
Parse error: syntax error, unexpected '$post_boilerplate' (T_VARIABLE), expecting function (T_FUNCTION) in /var/www/html/blog/index.php on line 79
Commenting out the HEREDOC too 'helps', in that the containing page gets generated, obviously albeit with errors pertaining to missing variable declarations, but obviously that's not actually solution.
Could anyone shed some light on what's wrong?