PHP How could I echo this html?

echo, html, php

Solution

First, you could just drop out of PHP and put in literal HTML:

?><option value="Bob's Weekend">Bob's Weekend</option><?php

Second, you could use backslashes:

echo '<option value="Bob\'s Weekend">Bob\'s Weekend</option>'; 

or

echo "<option value=\"Bob's Weekend\">Bob's Weekend</option>"; 

Finally, you could use a here-document:

echo <<<END
<option value="Bob's Weekend">Bob's Weekend</option>
END;

I would go with the first option, myself. It seems a bit silly to do `echo`'s in PHP code when all you have to do is drop back out of the PHP and everything is echoed automatically.

Problem

``` <option value="Bob's Weekend">Bob's Weekend</option> ``` I am stumped. The apostrophe is confusing the script and myself. How could I echo this in PHP? ``` echo '<option value="Bob's Weekend">Bob's Weekend</option>'; //syntax error echo '?><option value="Bob's Weekend">Bob's Weekend</option><?php ';?> //syntax error ```

Original source