-2

I have question, how to placing my html content like this:

<?php
$html = 
?>
//in this space, i will place my html
<span></span>
<?php
; 
?>
// and i print it
<?php echo $html;?>
Michael Antonius
  • 942
  • 2
  • 11
  • 20

3 Answers3

3

Why not just do that between the PHP tags?

<?php
  $html = '<span></span>';
  echo $html;
?>
Maritim
  • 2,111
  • 4
  • 29
  • 59
2

From what I understand you might want to have a look at heredoc syntax. However, your question is not exactly clear.

<?php
$html = <<<EOT
<span></span>
<!-- You can place anything in here "without escaping" -->
EOT;
echo $html;
?>
lawl0r
  • 840
  • 6
  • 16
2

You need output buffering for this.

<?php
ob_start();
?>
<!-- your html code here -->
<span></span>
<?php
$html = ob_get_clean();
?>
Jules Colle
  • 11,227
  • 8
  • 60
  • 67