...

View Full Version : How to put a html block into a $var



Peuplarchie
07-03-2007, 03:47 AM
Good day,
I was wondering how can I put a html block into a $var.

Thanks!

kbluhm
07-03-2007, 05:41 AM
Is this what you're talking about?

$html = '<div>This is HTML</div>';

_Aerospace_Eng_
07-03-2007, 06:03 AM
You may also want to look into heredoc syntax (http://us.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc).

hardnrg
07-03-2007, 07:44 AM
You can also try Output Buffering - something I use a lot, especially for those heavily templated websites.

<?php ob_start(); ?>

<p><strong>Hi there!</strong></p>
<p>I hope this helps you</p>

<?php $var = ob_get_contents(); ob_end_clean(); ?>
<?php

# manipulate $var here

?>

http://au.php.net/ob_start



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum