[FX.php List] Embed php into HTML or vice versa?

Kevin Futter kfutter at sbc.melb.catholic.edu.au
Thu Aug 31 18:19:21 MDT 2006


On 1/9/06 10:06 AM, "Steve Hannah" <shannah at sfu.ca> wrote:

> Hi Jonathan,
> 
> One tip for making HTML-in-PHP a little easier to work with is:
> 
> instead of
> echo "<td>".$value['StuList'][0]."</td>";
> 
> do
> 
> echo "<td>{$value['StuList'][0]}</td>";
> 
> That way you don't have to worry about forgetting a pesky
> concatenation operator.
> You can only do this inside double quotes, not single quotes, but it
> works for just about any valid PHP expression.
> 
> Best regards
> 
> Steve
> 

I'd actually handle it like this:

<td><?php echo $value['StuList'][0]; ?><td>

This way, the HTML is HTML, the PHP is PHP. No need to contatenate, or worry
about escaping quotes or other characters. This will work inside a foreach
loop as you write out the data too. As I've said in earlier posts, doing it
this way isn't always practical, but it's cleaner and more in the spirit of
separating the two.

-- 
Kevin Futter
Webmaster, St. Bernard's College
http://www.sbc.melb.catholic.edu.au/



------------------------------------------
This e-mail and any attachments may be confidential.  You must not disclose or use the information in this e-mail if you are not the intended recipient.  If you have received this e-mail in error, please notify us immediately and delete the e-mail and all copies.  The College does not guarantee that this e-mail is virus or error free.  The attached files are provided and may only be used on the basis that the user assumes all responsibility for any loss, damage or consequence resulting directly or indirectly from the use of the attached files, whether caused by the negligence of the sender or not.  The content and opinions in this e-mail are not necessarily those of the College.




More information about the FX.php_List mailing list