tags:

views:

82

answers:

3
A: 

The second example should work, except you said <php instead of <?php

philfreo
Yup, and the first one doesn't generate an output... it's just storing the value in a database
Franz
Also, in the second case, he forgot <?php as well
terminus
+1  A: 

There is no correct way. Outputting HTML within a switch is the same as outputting it anywhere else.

Gazler
+1  A: 

There's no correct way perse, both should work.

In your first example you need to make sure there is no space between <<< and EOM and no semicolon afterwards.

Example:

$myvar = <<<END
<div>My html here</div>
END;
echo $myvar;

another option would be to use:

echo "<div>My html here</div>";
Andy Baird
I would definitely vote for the first option. It tends to be a lot less messy when outputting a lot of HTML. Of course, if you are going to be working with large amounts of HTML, a template engine like Smarty makes things a LOT cleaner.
Atli