PHP sprintf() quick example

$template = ‘<div class=”%designIt”><img src=”%s” /><br />%s<br />by %s</div>’;
$designIt = “className”;
$imgSrc = “http://www.imageLivesHere.com/yo.jpg”;
$copyText = “What fabulous and interesting placeholder copy!”;
$sourceAuthor = “Me”;
$altogetherNow = sprintf ( $template, $imgSrc, $linkText, $sourceAuthor);

//Result

<div class=”className“>
<img src=”http://www.imageLivesHere.com/yo.jpg“/>
<br />
What fabulous and interesting placeholder copy!
<br />
by Me
</div>

Comments are closed.