Personally, I do not like mixing HTML and PHP… I would work with a “pure” PHP block and use here document to output HTML. Using <?php ?> in the middle of HTML gives me headaches at debug time, and I have already had problems like yours where PHP has “lost” the variables that you want to output!
Here doc allows you to output HTML without having to escape anything (“, ‘, etc) but still display PHP variables. Here doc works with echo and can also be entered into a variable (<<< replacing = as an affectation operator). The instruction is followed by 3 < symbols and a unique tag. The unique tag must be closed (unique tag followed by ?? on the first column of a new line
The syntax is
echo/$somthing <<< unique_tag_name
<!– Your HTML/javascript code –>
unique_tag_name;
Example:
<?php
$title = “extended title here”;
$description = “description here”;
$keywords = “keywords here”;
echo <<< here_doc_data
<title>$title</title>
<meta name=”description” content=”$description”>
<meta name=”keywords” content=”$keywords”>
here_doc_data;
<?
HTH,
Daniel