Is it possible to declare a variable value like or something similar:
<?php
$var =
?>
<!-- block of html code that goes into $var -->
<?php
//do anything with $var that contains the html code of above
?>
No this is not possible.
You can declare a variable in a php-block, then have that block terminate then some html part and then another php block and use it there.
But you cannot declare a variable like this, assigning the subsequent html contents to it.
But what you can do, as pointed out in Anders J's answer you can do the opposite, assign preceding contents to a variable. But note that there are some possible pitfalls.
Php is parsed by identifying the <?php ?> block first, everything outside of that is ignored by the parser, so in order to do this you would better have that html content in a separate file and read it into your variable using something like file_get_contents.
echo $var;at second part of php!Parse error: syntax error, unexpected '?> ' in index.php on line 8.$var, it is about your opening closing php tags. If you want to use$varinside of html,not php, you should write<?php echo $var; ?>inside of html after declaring of $var.file_get_contentsor something like that. Code between<php?and?>is understood by the parser to be php, code outside that is not.