If you want to avoid using placeholders or PHP code inside your template, you can look at phpQuery , which is the PHP Port for jQuery.
In your example, you would look like this (see docs ):
<?php
$body = 'The body of your email message';
$template = file_get_contents('template.html');
$email = pq('div.content').html($body);
?>
It may seem a little redundant, but if you intend to add more of the same features based on the CSS selector, just want to get the dirty hands of designers from PHP, this might be a good solution.
source
share